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

Prerequisites

  • Permissions are set for the administrator and target accounts. For more information, see Grant permissions on stack group operations.
  • A template is created. The resources to be created are defined. The following example shows 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"]
          }
        }
      }
    }

Background information

When you create 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. Log on to the ROS console.
  2. In the left-side navigation pane, click Stack Groups.
  3. In the upper-left corner, select a region from the drop-down list.
  4. On the Stack Groups page, click Create Stack Group.
  5. In the Select Template step of the Create Stack Group wizard, specify an ROS template, and then 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.

  6. In the Configure Template Parameters step of the Create Stack Group wizard, set Stack Group Name, Stack Group Description, and Parameters, and then click Next.
  7. In the Configure Stack Group step of the Create Stack Group wizard, set Admin Role and Execution Role as prompted, and then click Next.
    If you have set role permissions, click Next.
  8. In the Set Deployment Options step of the Create Stack Group wizard, set Accounts, Regions, Maximum Number of Concurrent Accounts, and Fault Tolerance, and then click Next.
    For more information about how to specify Maximum Number of Concurrent Accounts and Fault Tolerance, see Stack group deployment options.
  9. In the Check and 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.