All Products
Search
Document Center

Resource Orchestration Service:Create ECS instances across multiple accounts and regions

Last Updated:Apr 23, 2026

You can use Resource Orchestration Service (ROS) stack groups to create ECS instances with the same configuration across multiple Alibaba Cloud accounts and regions.

Prerequisites

  • If you use the self-managed permission model to create a stack group, ensure you have created an administrator account and target accounts. You must also manually create RAM roles in the administrator and target accounts to establish a trust relationship between them. For more information, see Grant self-managed permissions.

  • If you use the service-managed permission model to create a stack group, ensure you have set up a delegated administrator account. For more information, see Set up a delegated administrator account.

Step 1: Prepare the template

ROSTemplateFormatVersion: '2015-09-01'
Description: Creates One ECS instance
Resources:
  DS-InstanceTypes:
    Type: DATASOURCE::ECS::RecommendInstanceTypes
    Properties:
      Cores: 2
      Memory: 8
      SystemDiskCategory: cloud_essd
  Vpc:
    Type: ALIYUN::ECS::VPC
    Properties:
      CidrBlock: 192.168.0.0/16
  VSwitch:
    Type: ALIYUN::ECS::VSwitch
    Properties:
      VpcId:
        Ref: Vpc
      CidrBlock: 192.168.0.0/24
      ZoneId:
        Fn::Jq:
          - First
          - .[].ZoneId
          - Fn::GetAtt:
              - DS-InstanceTypes
              - InstanceTypes
  SecurityGroup:
    Type: ALIYUN::ECS::SecurityGroup
    Properties:
      VpcId:
        Ref: Vpc
  Instance:
    Type: ALIYUN::ECS::Instance
    Properties:
      IoOptimized: optimized
      PrivateIpAddress: 192.168.0.1
      VpcId:
        Ref: Vpc
      SecurityGroupId:
        Ref: SecurityGroup
      VSwitchId:
        Ref: VSwitch
      ImageId: centos
      InstanceType:
        Fn::Jq:
          - First
          - .[].InstanceType
          - Fn::GetAtt:
              - DS-InstanceTypes
              - InstanceTypes
      SystemDiskCategory: cloud_essd
Outputs:
  VpcId:
    Value:
      Fn::GetAtt:
        - Vpc
        - VpcId
  InstanceId:
    Value:
      Fn::GetAtt:
        - Instance
        - InstanceId

Template description:

  • The Resources section defines the resources to be created.

  • The Outputs section specifies that the IDs of the created VPC and ECS instance are returned after the stack is created.

Step 2: Create a stack group

  1. Log on to the ROS console.

  2. In the navigation pane on the left, click Stack Groups.

  3. From the region drop-down list in the top navigation bar, select the region for the stack group.

  4. On the Stack Groups page, click Create Stack Group.

  5. On the Select Template page, select Enter Template Content for Template Import Method, and paste the YAML template from Step 1: Prepare the template.

  6. On the Configure Parameters page, enter a Stack Group Name and Stack Group Description, and then click Next.

  7. In the Configure Stack Group step, set the permission model to Service-managed Permissions or Self-managed Permissions based on your business requirements, and click Next.

    For more information about service-managed permissions and self-managed permissions, see the "Permission models" section of the Overview topic.

  8. On the Set Deployment Options page, configure the deployment parameters, and then click Next.

    Note

    You can select up to 20 regions.

  9. On the Check and Confirm page, verify the stack group information and click Create Stack Group.

Step 3: View the stack group

  1. In the left-side navigation pane, click Stack Groups.

  2. On the Stack Groups page, find the stack group that you want to view and click the value in the Stack Group Name column.

  3. Click the Instance tab to view the created stack instances and their corresponding stack IDs.

  4. Click a Stack ID. On the Resources tab, you can view all the created resources.

    The ECS instance is successfully created when the Resource status is Succeeded.