All Products
Search
Document Center

Resource Orchestration Service:Use Count to deploy massive resources

Last Updated:Aug 22, 2023

In Resource Orchestration Service (ROS), you can use the Count parameter to create large numbers of resources at a time for complex or dynamic scenarios. This topic describes how to use the Count parameter to deploy massive resources.

Scale-out scenarios

The following section provides an example on how to use the Count parameter in a scale-out scenario to create a large number of pay-as-you-go Elastic Compute Service (ECS) instances. In this example, 3,000 ECS instances and 36,183 resources are created. The following table describes the resources.

Resource

Quantity

Description

ALIYUN::ECS::NetworkInterface

9,000

One ECS instance must be bound to three elastic network interfaces (ENIs).

ALIYUN::ECS::NetworkInterfaceAttachment

9,000

This resource type is used to bind ENIs to instances of the virtual private cloud (VPC) type.

ALIYUN::VPC::EIP

9,000

One elastic IP address (EIP) must be associated with one ENI.

ALIYUN::VPC::EIPAssociation

9,000

This resource type is used to associate EIPs with ENIs.

ALIYUN::ECS::InstanceGroup

3

One ALIYUN::ECS::InstanceGroup resource can contain up to 1,000 ECS instances.

ALIYUN::VPC::CommonBandwidthPackage

90

One hundred EIPs must be added to one EIP bandwidth plan.

ALIYUN::VPC::CommonBandwidthPackageIp

90

This resource type is used to add EIPs to Internet Shared Bandwidth instances.

One stack can contain up to 300 resources. To deploy 36,183 resources, you can use nested stacks together with the Count parameter.

Solution 1: basic solution

Assume that the number of ECS instances is M. Create specific resources in nested stacks and use a parent stack to integrate the resources.

  • Nested Stack A: In this stack, ECS instances are created, and EIPs are associated with ENIs.

    For example, the number of ECS instances in Nested Stack A is N. N is greater than or equal to 0 but less than or equal to 20. A maximum of 241 resources can be created in Nested Stack A, which is calculated based on the following formula: 1 + 240 = 241.

    • One ALIYUN::ECS::InstanceGroup resource is created for 20 ECS instances.

    • A maximum of 240 ENIs and EIPs can be created, which is calculated based on the following formula: 20 × 12 = 240.

  • Nested Stack B: In this stack, Internet Shared Bandwidth instances are created, and EIPs are added to the Internet Shared Bandwidth instances.

    Nested Stack B contains three Internet Shared Bandwidth instances. A maximum of six resources can be contained in Nested Stack B, which is calculated based on the following formula: (1 + 1) × 3 = 6.

    • The number of Internet Shared Bandwidth instances is three because one ECS instance is associated with three EIPs that link three networks.

    • One hundred EIPs must be added to one EIP bandwidth plan. Therefore, one Nested Stack B can contain up to 300 EIPs. Nested Stack A can contain 60 EIPs. Therefore, one Nested Stack B corresponds to five Nested Stacks A.

  • Parent stack: In this stack, nested stacks are integrated.

    The total number of resources is 180, which is calculated based on the following formula: 150 + 30 = 180. A single stack can contain the 180 resources.

    • The number of resources in Nested Stacks A is calculated based on the following expression: (M + 20 - 1)//20. The maximum value is 150. The outputs of every five Nested Stacks A is the input of one Nested Stack B. N is set to 0 for specific Nested Stacks A because the number of Nested Stacks A must be a multiple of 5. As a result, the number of resources in Nested Stacks A is calculated based on the following expression: ((M + 20 - 1)//20 + 4)//5 × 5. The maximum value is 150.

    • The number of resources in Nested Stack B is a fifth of the number of resources in Nested Stacks A, which is calculated based on the following expression: ((M + 20 - 1)//20 + 4)//5. The maximum value is 30.

Define templates.

  • Nested Stack A

    • Eni[0], Eni[1], and Eni[2] are bound to Servers[0]. Eni[3], Eni[4], and Eni[5] are bound to Servers[1]. In conclusion, Eni[3 × i], Eni[3 × i + 1], and Eni[3 × i + 2] are bound to Servers[i], where i is greater than or equal to 0 but less than or equal to N-1.

    • Eip-ChinaTelecom[i] is associated with Eni[3 × i], Eip-ChinaUnicom[i] is associated with Eni[3 × i + 1], and Eip-ChinaMobile[i] is associated with Eni[3 × i + 2], where i is greater than or equal to 0 but less than or equal to N-1. This way, one ECS instance is associated with three EIPs that belong to different Internet Service Providers (ISPs).

    Note

    In this example, China Telecom, China Unicom, and China Mobile are used as the ISPs.

    ROSTemplateFormatVersion: '2015-09-01'
    Parameters:
      NumberOfEcs:
        Type: Number
        MinValue: 0
        MaxValue: 20
    Conditions:
      NonEmpty:
        Fn::Not:
          Fn::Equals:
            - 0
            - Ref: NumberOfEcs
    Resources:
      Servers:
        Type: ALIYUN::ECS::InstanceGroup
        Condition: NonEmpty
        Properties:
          MinAmount:
            Ref: NumberOfEcs
          MaxAmount:
            Ref: NumberOfEcs
      Eni:
        Type: ALIYUN::ECS::NetworkInterface
        Count:
          Fn::Calculate:
            - '{0}*3'
            - 0
            - - Ref: NumberOfEcs
        Properties: null
      EniBinder:
        Type: ALIYUN::ECS::NetworkInterfaceAttachment
        Count:
          Fn::Calculate:
            - '{0}*3'
            - 0
            - - Ref: NumberOfEcs
        Properties:
          InstanceId:
            Fn::Select:
              - Fn::Calculate:
                  - '{0}//3'
                  - 0
                  - Ref: ALIYUN::Index
              - Fn::GetAtt:
                  - Servers
                  - InstanceIds
          NetworkInterfaceId:
            Fn::Select:
              - Ref: ALIYUN::Index
              - Ref: Eni
      Eip-ChinaTelecom:
        Type: ALIYUN::VPC::EIP
        Count:
          Ref: NumberOfEcs
        Properties:
          Isp: ChinaTelecom
      Eip-ChinaTelecom-Binder:
        Type: ALIYUN::VPC::EIPAssociation
        Count:
          Ref: NumberOfEcs
        Properties:
          InstanceId:
            Fn::Select:
              - Fn::Calculate:
                  - '{0}*3'
                  - 0
                  - - Ref: ALIYUN::Index
              - Ref: Eni
          AllocationId:
            Fn::Select:
              - Ref: ALIYUN::Index
              - Ref: Eip-ChinaTelecom
      Eip-ChinaUnicom:
        Type: ALIYUN::VPC::EIP
        Count:
          Ref: NumberOfEcs
        Properties:
          Isp: ChinaUnicom
      Eip-ChinaUnicom-Binder:
        Type: ALIYUN::VPC::EIPAssociation
        Count:
          Ref: NumberOfEcs
        Properties:
          InstanceId:
            Fn::Select:
              - Fn::Calculate:
                  - '{0}*3+1'
                  - 0
                  - - Ref: ALIYUN::Index
              - Ref: Eni
          AllocationId:
            Fn::Select:
              - Ref: ALIYUN::Index
              - Ref: Eip-ChinaUnicom
      Eip-ChinaMobile:
        Type: ALIYUN::VPC::EIP
        Count:
          Ref: NumberOfEcs
        Properties:
          Isp: ChinaMobile
      Eip-ChinaMobile-Binder:
        Type: ALIYUN::VPC::EIPAssociation
        Count:
          Ref: NumberOfEcs
        Properties:
          InstanceId:
            Fn::Select:
              - Fn::Calculate:
                  - '{0}*3+2'
                  - 0
                  - - Ref: ALIYUN::Index
              - Ref: Eni
          AllocationId:
            Fn::Select:
              - Ref: ALIYUN::Index
              - Ref: Eip-ChinaMobile
    Outputs:
      Eips-ChinaTelecom:
        Value:
          Ref: Eip-ChinaTelecom
      Eips-ChinaUnicom:
        Value:
          Ref: Eip-ChinaUnicom
      Eips-ChinaMobile:
        Value:
          Ref: Eip-ChinaMobile
  • Nested Stack B

    The following section provides an example of a standard template. In this example, the EIPs of different ISPs are added to the relevant Internet Shared Bandwidth instances of the ISPs.

    Note

    China Telecom, China Unicom, and China Mobile are used as the ISPs.

    ROSTemplateFormatVersion: '2015-09-01'
    Parameters:
      Eips-ChinaTelecom:
        Type: Json
      Eips-ChinaUnicom:
        Type: Json
      Eips-ChinaMobile:
        Type: Json
    Resources:
      CommonBandwidthPackage-ChinaTelecom:
        Type: ALIYUN::VPC::CommonBandwidthPackage
        Properties: null
      CommonBandwidthPackage-ChinaTelecom-IpBinder:
        Type: ALIYUN::VPC::CommonBandwidthPackageIp
        Properties:
          Eips:
            Ref: Eips-ChinaTelecom
          BandwidthPackageId:
            Ref: CommonBandwidthPackage-ChinaTelecom
      CommonBandwidthPackage-ChinaUnicom:
        Type: ALIYUN::VPC::CommonBandwidthPackage
        Properties: null
      CommonBandwidthPackage-ChinaUnicom-IpBinder:
        Type: ALIYUN::VPC::CommonBandwidthPackageIp
        Properties:
          Eips:
            Ref: Eips-ChinaUnicom
          BandwidthPackageId:
            Ref: CommonBandwidthPackage-ChinaUnicom
      CommonBandwidthPackage-ChinaMobile:
        Type: ALIYUN::VPC::CommonBandwidthPackage
        Properties: null
      CommonBandwidthPackage-ChinaMobile-IpBinder:
        Type: ALIYUN::VPC::CommonBandwidthPackageIp
        Properties:
          Eips:
            Ref: Eips-ChinaMobile
          BandwidthPackageId:
            Ref: CommonBandwidthPackage-ChinaMobile
  • Parent stack

    Add the templates of Nested Stack A and Nested Stack B to specific Object Storage Service (OSS) buckets. Templates for nested stacks must be provided by using URLs. Assume that the template URL of Nested Stack A is oss://templates/resourses-a, and the template URL of Nested Stack B is oss://templates/resourses-b.

    • Resource A is Nested Stack A.

      The value of the NumberOfEcs parameter is calculated based on the following expression: (1 - (({1} + 1)//(({0} + 19)//20 + 1) + 999)//1000) × ((({0} - 20 × {1})//20 + {0})//({0} + 1) × (20 - ({0} - {0}//20 × 20)) + ({0} - {0}//20 × 20)). The following section shows how to calculate the value:

      • Limits: Fn::Calculate supports only the following operators: addition (+), subtraction (-), multiplication (×), floating division (/), and integer division (//).

      • Value extraction rules: Starting from Group 0, 20 resources are taken from M resources each time. If the number of resources is less than 20, the remaining resources are taken. If no resources are left, the value of the NumberOfEcs parameter is 0. The following examples show how the values of the NumberOfEcs parameter is calculated in Nested Stack A:

        • When the value of M is 1 and the Count parameter value of Nested Stack A is 5, the values of the NumberOfEcs parameter are arranged in the following sequence: 1, 0, 0, 0, 0.

        • When the value of M is 20 and the Count parameter value of Nested Stack A is 5, the values of the NumberOfEcs parameter are arranged in the following sequence: 20, 0, 0, 0, 0.

        • When the value of M is 99 and the Count parameter value of Nested Stack A is 5, the values of the NumberOfEcs parameter are arranged in the following sequence: 20, 20, 20, 20, 19.

        • When the value of M is 100 and the Count parameter value of Nested Stack A is 5, the values of the NumberOfEcs parameter are arranged in the following sequence: 20, 20, 20, 20, 20.

        • When the value of M is 101 and the Count parameter value of Nested Stack A is 10, the values of the NumberOfEcs parameter are arranged in the following sequence: 20, 20, 20, 20, 20, 1, 0, 0, 0, 0.

      • Math tips:

        • Tip 1: Method to convert the sequence 0, 1, 2, ... into the sequence 0, 1, 1, ...

          You can use the following formula: F(x, t) = (x + t)//(t + 1), where t is greater than or equal to Max(x). When x is set to 0, F(0) is equal to 0. When x is greater than or equal to 1, F(x) is equal to 1 because F(x) must be greater than or equal to 1. F(x) is calculated based on the following formula: F(x) = (x + t)//(t + 1) <= (x + Max(x))//(Max(x) + 1) <= (Max(x) + Max(x))//(Max(x) + 1) < 2.

        • Tip 2: Method to convert the sequence 0, 1 into the sequence P, Q

          For example, x is set to 0 or 1 in the G(x, P, Q) = x × (Q - P) + P formula. If x is set to 0, f(0) is equal to P. If x is set to 1, f(1) is equal to Q.

        • Tip 3: Method to calculate the remainders of M and N

          You can use the following formula: M%N = M - M//N × N.

      • Expressions:

        Create the following definitions: N = 20, U = (M + N - 1)//N, and V = (U + 4)//5 × 5. In the definitions, U specifies the number of Nested Stack A before the number is counted as a multiple of 5, and V specifies the actual number of Nested Stack A after the number is counted as a multiple of 5.

        For example, M is set to 101. i specifies the serial number that corresponds to the ALIYUN::Index pseudo parameter. The values of f(i) are calculated by using the f(i) = (M - N × i)//N formula based on the following conditions: 0 <= i< V, U = 6, and V = 10. The following f(i) values are obtained: f(0) = 5, f(1) = 4, f(2) = 3, f(3) = 2, f(4) = 1, f(5) = 0, f(6) = -1, f(7) = -2, f(8) = -3, and f(9) = -4.

        • 0<=i<U

          You can refer to Tip 1 to convert the sequence 5, 4, 3, 2, 1, 0 into the sequence 1, 1, 1, 1, 1, 0.

          If t = M >= Max(f(i)), g(i) is calculated based on the following formula: g(i) = F(f(i), M) = ((M - N × i)//N + M)//(M + 1). This is a sequence function. You can refer to Tip 2 to convert the sequence 5, 4, 3, 2, 1, 0 into the sequence 20, 20, 20, 20, 20, 1. The values in the new sequence are the values of the NumberOfEcs parameter if 0 <= i < U.

          If P = M%N and Q = N, h(i) is calculated based on the following formula: h(i) = G(g(i), M%N, N) = (((M - N × i)//N + M)//(M + 1)) × (N - (M - M//N × N)) + (M - M//N × N).

        • i>=U

          If 0 <= i < U, the value is 1. If i >= U, the value is 0. If 0 <= i < U, the value of k(i) = (i + 1)//(U + 1) is 0. If i >= U, the value of k(i) = (i + 1)//(U + 1) is greater than or equal to 1.

          You can refer to Tip 1 to convert the values into the sequence 0, 1. The maximum value of k(i) can be calculated based on the following formula: Max(k(i)) = V//(U + 1) = (U + 4)//5 × 5//(U + 1) <= 4. t can be set to 4, but it is set to 999 in this example.

          The new sequence is calculated based on the following formula: p(i) = 1 - F(k(i), 999) = 1 - ((i + 1)//((M + N - 1)//N + 1) + 999)//1000. If 0 <= i < U, the value is 1. If i >= U, the value is 0.

        The final sequence is calculated based on the following formula: q(i) = p(i) × h(i) = (1 - ((i + 1)//((M + N - 1)//N + 1) + 999)//1000) × (((M - N × i)//N + M)//(M + 1)) × (N - (M - M//N × N)) + (M - M//N × N). If M = {0}, i = {1}, and N = 20, q(i) is calculated based on the following formula: q(i) = (1 - (({1} + 1)//(({0} + 19)//20 + 1) + 999)//1000) × ((({0} - 20 × {1})//20 + {0})//({0} + 1) × (20 - ({0} - {0}//20 × 20)) + ({0} - {0}//20 × 20)).

    • Resource B is Nested Stack B.

      Nested Stack B[i] uses the outputs of A[5 × i], A[5 × i + 1], A[5 × i + 2], A[5 × i + 3], and A[5 × i + 4] as the input.

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  NumberOfEcs:
    Type: Number
    MinValue: 0
Resources:
  A:
    Type: ALIYUN::ROS::Stack
    Count:
      Fn::Calculate:
        - (({0}+19)//20+4)//5*5
        - 0
        - - Ref: NumberOfEcs
    Properties:
      TemplateURL: oss://templates/resourses-a
      Parameters:
        NumberOfEcs:
          Fn::Calculate:
            - (1-(({1}+1)//(({0}+19)//20+1)+999)//1000)*((({0}-20*{1})//20+{0})//({0}+1)*(20-({0}-{0}//20*20))+({0}-{0}//20*20))
            - 0
            - - Ref: NumberOfEcs
              - Ref: ALIYUN::Index
  B:
    Type: ALIYUN::ROS::Stack
    Count:
      Fn::Calculate:
        - (({0}+19)//20+4)//5
        - 0
        - - Ref: NumberOfEcs
    Properties:
      TemplateURL: oss://templates/resourses-b
      Parameters:
        Eips-ChinaTelecom:
          Fn::ListMerge:
            - Fn::Select:
                - Fn::Calculate:
                    - 5*{0}
                    - 0
                    - - Ref: ALIYUN::Index
                - Fn::GetAtt:
                    - A
                    - Eips-ChinaTelecom
            - Fn::Select:
                - Fn::Calculate:
                    - 5*{0}+1
                    - 0
                    - - Ref: ALIYUN::Index
                - Fn::GetAtt:
                    - A
                    - Eips-ChinaTelecom
            - Fn::Select:
                - Fn::Calculate:
                    - 5*{0}+2
                    - 0
                    - - Ref: ALIYUN::Index
                - Fn::GetAtt:
                    - A
                    - Eips-ChinaTelecom
            - Fn::Select:
                - Fn::Calculate:
                    - 5*{0}+3
                    - 0
                    - - Ref: ALIYUN::Index
                - Fn::GetAtt:
                    - A
                    - Eips-ChinaTelecom
            - Fn::Select:
                - Fn::Calculate:
                    - 5*{0}+4
                    - 0
                    - - Ref: ALIYUN::Index
                - Fn::GetAtt:
                    - A
                    - Eips-ChinaTelecom

One Nested Stack B corresponds to five Nested Stack A. You can use a slice object that is constructed by using Start:Stop:Step in Fn::Select to dynamically select multiple elements from a list.

You can invoke the Fn::Min function in the Zenus resource management system to simplify expressions. The following sample code shows a template in which expressions are simplified:

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  NumberOfEcs:
    Type: Number
    MinValue: 0
Resources:
  A:
    Type: ALIYUN::ROS::Stack
    Count:
      Fn::Calculate:
        - ({0}+19)//20
        - 0
        - - Ref: NumberOfEcs
    Properties:
      TemplateURL: oss://templates/resourses-a
      Parameters:
        NumberOfEcs:
          Fn::Min:
            - 20
            - Fn::Calculate:
                - '{0}-{1}*20'
                - 0
                - - Ref: NumberOfEcs
                  - Ref: ALIYUN::Index
  B:
    Type: ALIYUN::ROS::Stack
    Count:
      Fn::Calculate:
        - (({0}+19)//20+4)//5
        - 0
        - - Ref: NumberOfEcs
    Properties:
      TemplateURL: oss://templates/resourses-b
      Parameters:
        Eips-ChinaTelecom:
          Fn::ListMerge:
            - Fn::Select:
                - Fn::Replace:
                    - Start:
                        Fn::Calculate:
                          - 5*{0}
                          - 0
                          - - Ref: ALIYUN::Index
                      Stop:
                        Fn::Calculate:
                          - 5*({0}+1)
                          - 0
                          - - Ref: ALIYUN::Index
                    - Start:Stop
                - Fn::GetAtt:
                    - A
                    - Eips-ChinaTelecom

Solution 2: optimized solution

Reallocate the resources by performing the following operations:

  • Add ALIYUN::VPC::CommonBandwidthPackageIp resources to Nested Stack A.

  • Add ALIYUN::VPC::CommonBandwidthPackage resources to Nested Stack B. You must use the Count parameter for the number of resources in Nested Stack B, but not for the number of Nested Stack B. Nested Stack B provides the list of IDs of Internet Shared Bandwidth instances and passes the list to Nested Stack A.

Use dynamic parameters:

  • Replace the maximum number of ECS instances (20) by using the value of the MaxNumberOfEcsPerStack parameter.

  • Replace the maximum number of EIPs (100) that can be added to one EIP bandwidth plan by using the value of the MaxNumberOfEipPerBandwidthPackage parameter.

  • When you create Nested Stack A in a parent stack, set EipIndexOffset to the product of ALIYUN::Index and MaxNumberOfEcsPerStack.

  • In Nested Stack A, use the ALIYUN::VPC::CommonBandwidthPackageIp resource to group EIPs. Then, add separate groups to separate Internet Shared Bandwidth instances.

The following section shows the optimized templates.

  • Nested Stack A

    Set A to EipIndexOffset, B to NumberOfEcs, C to MaxNumberOfEipPerBandwidthPackage, and i to ALIYUN::Index. The A//C expression specifies the serial number of the EIP bandwidth plan with which the first EIP in the stack is associated. The (A + B - 1)//C expression specifies the serial number of the EIP bandwidth plan to which the last EIP in the stack is associated. Therefore, CommonBandwidthPackage-ChinaTelecom-IpBinder.Count is equal to ((A + B - 1)//C - A//C) + 1.

    CommonBandwidthPackage-ChinaTelecom-IpBinder.BandwidthPackageId is equal to CommonBandwidthPackage-ChinaTelecom-List[A//C + i]. The following solution to distribute Eip-ChinaTelecom from its group to CommonBandwidthPackage-ChinaTelecom-IpBinder is taken into global consideration:

    The global serial number is within [(A//C + i) × C, (A//C + i + 1) × C) and is subject to CommonBandwidthPackage-ChinaTelecom-IpBinder[(A//C + i)]. To convert the global serial number into a local serial number, you need to only use the [(A//C + i) × C - A, (A//C + i + 1) × C - A) expression to deduct the offset. Note that the range must be within [0, B]. Therefore, the result is [Max((A//C + i) × C - A, 0), Min((A//C + i + 1) × C - A, B)].

    ROSTemplateFormatVersion: '2015-09-01'
    Parameters:
      NumberOfEcs:
        Type: Number
        MinValue: 1
      MaxNumberOfEipPerBandwidthPackage:
        Type: Number
        MinValue: 1
      EipIndexOffset:
        Type: Number
      CommonBandwidthPackage-ChinaTelecom-List:
        Type: Json
      CommonBandwidthPackage-ChinaUnicom-List:
        Type: Json
      CommonBandwidthPackage-ChinaMobile-List:
        Type: Json
    Conditions:
      NonEmpty:
        Fn::Not:
          Fn::Equals:
            - 0
            - Ref: NumberOfEcs
    Resources:
      CommonBandwidthPackage-ChinaTelecom-IpBinder:
        Type: ALIYUN::VPC::CommonBandwidthPackageIp
        Count:
          Fn::Calculate:
            - (({0}+{1}-1)//{2}-{0}//{2})+1
            - 0
            - - Ref: EipIndexOffset
              - Ref: NumberOfEcs
              - Ref: MaxNumberOfEipPerBandwidthPackage
        Properties:
          Eips:
            Fn::Select:
              - Fn::Replace:
                  - Start:
                      Fn::Max:
                        - 0
                        - Fn::Calculate:
                            - ({0}//{2}+{1})*{2}-{0}
                            - 0
                            - - Ref: EipIndexOffset
                              - Ref: ALIYUN::Index
                              - Ref: MaxNumberOfEipPerBandwidthPackage
                    Stop:
                      Fn::Min:
                        - Ref: NumberOfEcs
                        - Fn::Calculate:
                            - ({0}//{2}+{1}+1)*{2}-{0}
                            - 0
                            - - Ref: EipIndexOffset
                              - Ref: ALIYUN::Index
                              - Ref: MaxNumberOfEipPerBandwidthPackage
                  - Start:Stop
              - Ref: Eip-ChinaTelecom
          BandwidthPackageId:
            Fn::Select:
              - Fn::Calculate:
                  - '{0}//{2}+{1}'
                  - 0
                  - - Ref: EipIndexOffset
                    - Ref: ALIYUN::Index
                    - Ref: MaxNumberOfEipPerBandwidthPackage
              - Ref: CommonBandwidthPackage-ChinaTelecom-List
  • Nested Stack B

    ROSTemplateFormatVersion: '2015-09-01'
    Parameters:
      Count:
        Type: Number
    Resources:
      CommonBandwidthPackage-ChinaTelecom:
        Type: ALIYUN::VPC::CommonBandwidthPackage
        Count:
          Ref: Count
        Properties: null
      CommonBandwidthPackage-ChinaUnicom:
        Type: ALIYUN::VPC::CommonBandwidthPackage
        Count:
          Ref: Count
        Properties: null
      CommonBandwidthPackage-ChinaMobile:
        Type: ALIYUN::VPC::CommonBandwidthPackage
        Count:
          Ref: Count
        Properties: null
    Outputs:
      CommonBandwidthPackage-ChinaTelecom-List:
        Value:
          Ref: CommonBandwidthPackage-ChinaTelecom
      CommonBandwidthPackage-ChinaUnicom-List:
        Value:
          Ref: CommonBandwidthPackage-ChinaUnicom
      CommonBandwidthPackage-ChinaMobile-List:
        Value:
          Ref: CommonBandwidthPackage-ChinaMobile
  • Parent stack

    ROSTemplateFormatVersion: '2015-09-01'
    Parameters:
      NumberOfEcs:
        Type: Number
        MinValue: 0
      MaxNumberOfEcsPerStack:
        Type: Number
        MinValue: 1
        Default: 20
      MaxNumberOfEipPerBandwidthPackage:
        Type: Number
        MinValue: 1
        Default: 100
    Resources:
      B:
        Type: ALIYUN::ROS::Stack
        Properties:
          TemplateURL: oss://templates/resourses-b
          Parameters:
            Count:
              Fn::Calculate:
                - ({0}+{1}-1)//{1}
                - 0
                - - Ref: NumberOfEcs
                  - Ref: MaxNumberOfEipPerBandwidthPackage
      A:
        Type: ALIYUN::ROS::Stack
        Count:
          Fn::Calculate:
            - ({0}+{1}-1)//{1}
            - 0
            - - Ref: NumberOfEcs
              - Ref: MaxNumberOfEcsPerStack
        Properties:
          TemplateURL: oss://templates/resourses-a
          Parameters:
            NumberOfEcs:
              Fn::Min:
                - Ref: MaxNumberOfEcsPerStack
                - Fn::Calculate:
                    - '{0}-{1}*{2}'
                    - 0
                    - - Ref: NumberOfEcs
                      - Ref: ALIYUN::Index
                      - Ref: MaxNumberOfEcsPerStack
            MaxNumberOfEipPerBandwidthPackage:
              Ref: MaxNumberOfEipPerBandwidthPackage
            EipIndexOffset:
              Fn::Calculate:
                - '{0}*{1}'
                - 0
                - - Ref: MaxNumberOfEcsPerStack
                  - Ref: ALIYUN::Index
            CommonBandwidthPackage-ChinaTelecom-List:
              Fn::GetAtt:
                - B
                - CommonBandwidthPackage-ChinaTelecom-List
            CommonBandwidthPackage-ChinaUnicom-List:
              Fn::GetAtt:
                - B
                - CommonBandwidthPackage-ChinaUnicom-List
            CommonBandwidthPackage-ChinaMobile-List:
              Fn::GetAtt:
                - B
                - CommonBandwidthPackage-ChinaMobile-List