All Products
Search
Document Center

Resource Orchestration Service:Create an ECS instance within multiple accounts and regions

Last Updated:Feb 18, 2024

You can use the stack group feature of Resource Orchestration Service (ROS) to create an Elastic Compute Service (ECS) instance that is configured with the same settings within multiple Alibaba Cloud accounts and regions.

Prerequisites

  • If you want to use the self-managed permission model to create a stack group, make sure that you have completed the following operations: Create administrator and execution accounts, create Resource Access Management (RAM) roles within the accounts, and then establish a trust relationship between the accounts. For more information, see Step 1: Grant self-managed permissions.

  • If you want to use the service-managed permission model to create a stack group, make sure that you have created a delegated administrator account. For more information, see Step 1: (Optional) Create a delegated administrator account.

Step 1: Create a 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

The template contains the following sections:

  • Resources: The system creates resources based on the resource settings that you configure in the section.

  • Outputs: The system returns the ID of the created virtual private clouds (VPC) and ECS instance based on the output parameters that you specify in the section.

Step 2: Create a stack group

  1. Log on to the ROS console.

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

  3. In the top navigation bar, select the region where you want to create a stack group from the region drop-down list.

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

  5. In the Select Template step, select Select an Existing Template, set Template Import Method to Enter Template Content, and then enter the YAML template that you created in Step 1: Create a template.

  6. In the Configure Parameters step, configure the Stack Group Name and Stack Group Description parameters, and click Next.

  7. In the Configure Stack Group step, set the permission model to Self-managed Permissions or Service-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. In the Set Deployment Options step, configure the parameters that are required to deploy the stack group and click Next.

    • If you selected the service-managed permission model to create the stack group, select multiple members in the resource directory in the Deployment Destinations section and select multiple regions.

      Configure other parameters based on your business requirements. For more information, see Step 3: Create a stack group.

    • If you selected the self-managed permission model to create the stack group, set Deployment Locations to Deploy Stacks Within Accounts, enter multiple accounts, and then select multiple regions.

      Configure other parameters based on your business requirements. For more information, see Step 2: Create a stack group.

    Note

    You can select up to 20 regions.

  9. In the Check and Confirm step, confirm the information about the stack group 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 Instances tab to view the stack instances that are created in the stack group and the relevant stack IDs.

    001

  4. In the Stack ID column, click the ID of the stack that you want to manage to go to the Resources tab. On this tab, view all the resources that are created in the stack.

    If Created appears in the Resource Status column of the ECS instance, the ECS instance is created. 002