All Products
Search
Document Center

CloudOps Orchestration Service:ACS-ECS-CloneInstancesAcrossAZ

Last Updated:Dec 24, 2025

Template name

ACS-ECS-CloneInstancesAcrossAZ clones multiple ECS instances across zones

Execute Now

Template description

Clones multiple Elastic Compute Service (ECS) instances at a time across zones.

Template type

Automated

Owner

Alibaba Cloud

Input parameters

Parameter

Description

Type

Required

Default value

Limit

targets

Target instance

Json

Yes

targetSecurityGroupId

The ID of the security group of the cloned ECS instances.

String

Yes

targetVSwitchId

The vSwitch ID of the cloned ECS instances. If you specify this parameter, the zone to which the ECS instances are cloned is specified.

String

Yes

targetTags

The tags of the cloned ECS instances.

Json

Yes

regionId

The region ID.

String

No

{{ ACS::RegionId }}

targetResourceGroupId

The ID of the resource group to which the cloned ECS instances are added.

String

No

targetInstanceType

The instance type of the cloned ECS instances.

String

No

targetInstanceChargeType

The billing method of the cloned ECS instances. By default, this parameter is set to PostPaid.

String

No

PostPaid

targetPeriodUnit

The unit of subscription duration that is available if the billing method of the cloned ECS instances is set to subscription. By default, this parameter is set to Month.

String

No

targetPeriod

The subscription duration that is available if the billing method of the cloned ECS instances is set to subscription. By default, this parameter is set to 1.

Number

No

1

targetDeploymentSetId

The ID of the deployment set to which the cloned ECS instances belong.

String

No

targetInstanceName

Instance name

String

No

targetHostName

The hostname of the cloned ECS instances.

String

No

rateControl

Concurrency rate and fault tolerance count for task execution in a loop

Json

No

{'Mode': 'Concurrency', 'MaxErrors': 0, 'Concurrency': 10}

OOSAssumeRole

The Resource Access Management (RAM) role that is assumed by CloudOps Orchestration Service (OOS).

String

No

""

Output parameters

Parameter

Description

Type

instanceIds

List

Permission policy that is required to execute the template

{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "ecs:CreateImage",
                "ecs:DeleteImage",
                "ecs:DescribeAvailableResource",
                "ecs:DescribeDisks",
                "ecs:DescribeImages",
                "ecs:DescribeInstances",
                "ecs:DescribeVSwitches",
                "ecs:RunInstances"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "oos:GetApplicationGroup"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}

Details

Details of ACS-ECS-CloneInstancesAcrossAZ

Template content

FormatVersion: OOS-2019-06-01
Description:
  en: Clones ECS instances in batches across availability zones.
  zh-cn: 跨可用区批量克隆ECS实例
  name-en: ACS-ECS-CloneInstancesAcrossAZ
  name-zh-cn: 跨可用区批量克隆ECS实例
  categories:
    - cross_region
Parameters:
  regionId:
    Type: String
    Label:
      en: Region ID
      zh-cn: 地域ID
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  targets:
    Label:
      en: Target Instances
      zh-cn: 目标实例
    Type: Json
    AssociationProperty: Targets
    AssociationPropertyMetadata:
      ResourceType: 'ALIYUN::ECS::Instance'
      RegionId: regionId
  targetSecurityGroupId:
    Label:
      en: The security group ID for the new instances.
      zh-cn: 新实例的安全组ID
    Type: String
    AssociationProperty: 'ALIYUN::ECS::SecurityGroup::SecurityGroupId'
    AssociationPropertyMetadata:
      RegionId: regionId
  targetVSwitchId:
    Label:
      en: The vSwitch ID for the new instances. This parameter determines the destination zone.
      zh-cn: 新实例的交换机ID,填写本参数时将会决定目的可用区
    Type: String
    AssociationProperty: 'ALIYUN::VPC::VSwitch::VSwitchId'
    AssociationPropertyMetadata:
      RegionId: regionId
      Filters:
        - SecurityGroupId: targetSecurityGroupId
  targetResourceGroupId:
    Label:
      en: The ID of the resource group to which the new instances will be added.
      zh-cn: 新实例将加入的目的资源组ID
    Type: String
    Default: ' '
  targetInstanceType:
    Label:
      en: The instance type for the new instances.
      zh-cn: 新实例的规格
    Type: String
    AssociationProperty: 'ALIYUN::ECS::Instance::InstanceType'
    AssociationPropertyMetadata:
      RegionId: regionId
    Default: ' '
  targetTags:
    Label:
      en: The tags for the new instances.
      zh-cn: 新实例的标签
    Type: Json
    AssociationProperty: Tags
    AssociationPropertyMetadata:
      ShowSystem: false
  targetInstanceChargeType:
    Label:
      en: The billing method for the new instances. The default is pay-as-you-go.
      zh-cn: 新实例的付费模式,默认按量付费
    Type: String
    AllowedValues:
      - PrePaid
      - PostPaid
    Default: PostPaid
  targetPeriodUnit:
    Label:
      en: The unit of the subscription duration. This parameter is required only when the billing method is subscription (PrePaid). The default is Month.
      zh-cn: 当新实例的付费方式选择包年包月时,请在此处选择时长单位,默认单位是月
    Type: String
    AllowedValues:
      - Week
      - Month
      - ' '
    Default: ' '
  targetPeriod:
    Label:
      en: The subscription duration. This parameter is required only when the billing method is subscription (PrePaid). The default is 1.
      zh-cn: 当新实例的付费方式选择包年包月时,请在此处填写时长数,默认值为1
    Type: Number
    Default: 1
  targetDeploymentSetId:
    Label:
      en: The deployment set ID for the new instances.
      zh-cn: 新实例的部署集ID
    Type: String
    Default: ' '
  targetInstanceName:
    Label:
      en: The name of the new instances.
      zh-cn: 新实例的名称
    Type: String
    Default: ' '
  targetHostName:
    Label:
      en: The hostname of the new instances.
      zh-cn: 新实例的主机名称
    Type: String
    Default: ' '
  rateControl:
    Label:
      en: The concurrency rate and error tolerance for the loop task.
      zh-cn: 循环任务执行的并发率及容错数
    Type: Json
    AssociationProperty: RateControl
    Default:
      Mode: Concurrency
      MaxErrors: 0
      Concurrency: 10
  OOSAssumeRole:
    Label:
      en: The RAM role that OOS assumes.
      zh-cn: OOS扮演的RAM角色
    Type: String
    Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: getInstance
    Description:
      en: Gets the specified ECS instances.
      zh-cn: 获取ECS实例
    Action: 'ACS::SelectTargets'
    Properties:
      RegionId: '{{regionId}}'
      ResourceType: 'ALIYUN::ECS::Instance'
      Filters:
        - '{{ targets }}'
    Outputs:
      instanceIds:
        Type: List
        ValueSelector: 'Instances.Instance[].InstanceId'

  - Name: cloneInstancesAcrossAZ
    Action: 'ACS::Template'
    Description:
      en: Clone instances
      zh-cn: 克隆实例
    Properties:
      TemplateName: 'ACS::ECS::CloneInstanceAcrossAZ'
      Parameters:
        imageName: 'img-{{ ACS::TaskLoopItem }}-{{ACS::ExecutionId}}'
        instanceId: '{{ ACS::TaskLoopItem }}'
        targetSecurityGroupId: '{{ targetSecurityGroupId }}'
        targetResourceGroupId: '{{ targetResourceGroupId }}'
        targetVSwitchId: '{{ targetVSwitchId }}'
        regionId: '{{ regionId }}'
        targetInstanceName: '{{ targetInstanceName }}'
        targetInstanceChargeType: '{{ targetInstanceChargeType }}'
        targetPeriodUnit: '{{ targetPeriodUnit }}'
        targetPeriod: '{{ targetPeriod }}'
        targetInstanceType: '{{ targetInstanceType }}'
        targetHostName: '{{ targetHostName }}'
        targetDeploymentSetId: '{{ targetDeploymentSetId }}'
        tags: '{{ targetTags }}'
        OOSAssumeRole: '{{OOSAssumeRole}}'
    Loop:
      Items: '{{ getInstance.instanceIds }}'
      RateControl: '{{ rateControl }}'
      Outputs:
        instanceIds:
          AggregateType: 'Fn::ListJoin'
          AggregateField: instanceId
    Outputs:
      instanceId:
        ValueSelector: instanceId
        Type: String
Outputs:
  instanceIds:
    Value: '{{ cloneInstancesAcrossAZ.instanceIds }}'
    Type: List
Metadata:
  ALIYUN::OOS::Interface:
    ParameterGroups:
      - Parameters:
          - targetSecurityGroupId
          - targetVSwitchId
          - targetInstanceType
          - targetTags
          - targetInstanceChargeType
          - targetPeriodUnit
          - targetPeriod
          - targetResourceGroupId
          - targetDeploymentSetId
          - targetInstanceName
          - targetHostName
        Label:
          default:
            zh-cn: 设置参数
            en: Configure Parameters
      - Parameters:
          - regionId
          - targets
        Label:
          default:
            zh-cn: 选择实例
            en: Select Instances
      - Parameters:
          - rateControl
          - OOSAssumeRole
        Label:
          default:
            zh-cn: 高级选项
            en: Advanced Options