A stack group lets you use a single ROS template to create stacks in multiple Alibaba Cloud accounts across regions. All resources included in each stack are defined by the ROS template of the stack group.

Prerequisites

Ensure that you have set permissions for the administrator and target accounts. For more information, see Grant permissions on stack group operations.

Background information

When creating a stack group, you must specify an ROS template that you want to use to create stacks, the target accounts in which you want to create stacks, and the regions in which you want to deploy stacks to your target accounts. A stack group ensures consistent deployment of identical stack resources with identical settings to all specified target accounts within the regions you choose.

Procedure

  1. Prepare a template.
    Before creating a stack group, you must prepare an ROS template and define the resources to be created. The following example provides a template that creates a VPC, VSwitch, security group, and ECS instance:
    {
      "ROSTemplateFormatVersion": "2015-09-01",
      "Parameters": {
        "InstanceType": {
          "Type": "String",
          "Default": "ecs.g6.large"
        }
      },
      "Resources": {
        "Vpc": {
          "Type": "ALIYUN::ECS::VPC",
          "Properties": {
            "CidrBlock": "192.168.0.0/16"
          }
        },
        "VSwitch": {
          "Type": "ALIYUN::ECS::VSwitch",
          "Properties": {
            "CidrBlock": "192.168.0.0/24",
            "VpcId": {
              "Ref": "Vpc"
            },
            "ZoneId": {
              "Fn::Select": [
                "0",
                {
                  "Fn::GetAZs": {
                    "Ref": "ALIYUN::Region"
                  }
                }
              ]
            }
          }
        },
        "SecurityGroup": {
          "Type": "ALIYUN::ECS::SecurityGroup",
          "Properties": {
            "VpcId": {
              "Ref": "Vpc"
            }
          }
        },
        "InstanceGroup": {
          "Type": "ALIYUN::ECS::InstanceGroup",
          "Properties": {
            "MaxAmount": 2,
            "InstanceType": {
              "Ref": "InstanceType"
            },
            "ImageId": "centos_7",
            "VpcId": {
              "Ref": "Vpc"
            },
            "VSwitchId": {
              "Ref": "VSwitch"
            },
            "SecurityGroupId": {
              "Ref": "SecurityGroup"
            }
          }
        }
      },
      "Outputs": {
        "InstanceIds": {
          "Value": {
            "Fn::GetAtt": ["InstanceGroup", "InstanceIds"]
          }
        }
      }
    }
  2. Log on to the Resource Orchestration Service (ROS) console.
  3. Select the region where you want to create the stack group from the drop-down list in the upper-left corner.
  4. In the left-side navigation pane, click Stack Groups.
  5. On the Stack Groups page, click Create Stack Group.
  6. In the Select Template step of the Create Stack Group wizard, enter the ROS template content and click Next.

    You can select an existing template or use a sample template.

    A template is a JSON or YAML file encoded in UTF-8. For more information about templates, see Template structure.

  7. In the Configure Template Parameters step of the Create Stack Group wizard, set Stack Group Name and Parameters as prompted, and click Next.
  8. In the Configure Stack Group step of the Create Stack Group wizard, set Admin Role and Execution Role as prompted, and click Next.
    If you have set role permissions, click Next.
  9. In the Set Deployment Options step of the Create Stack Group wizard, configure the accounts, regions, maximum number of concurrent accounts, and fault tolerance for the stack group as prompted, and click Next.
    For information about how to set Maximum Number of Concurrent Accounts and Fault Tolerance, see Stack group deployment options.
  10. In the Confirm step of the Create Stack Group wizard, click Create Stack Group.
    You can view information about the created stack group on the Stack Groups page.