All Products
Search
Document Center

CloudOps Orchestration Service:ACS-ECS-CloneInstancesAcrossAZ

Last Updated:Nov 26, 2024

Template name

ACS-ECS-CloneInstancesAcrossAZ

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

The ECS instances that you want to clone.

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

The name of the cloned ECS instances.

String

No

targetHostName

The hostname of the cloned ECS instances.

String

No

rateControl

The rate control settings.

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"
        }
    ]
}

References

For more information, see ACS-ECS-CloneInstancesAcrossAZ.yml at GitHub.

Template content

FormatVersion: OOS-2019-06-01
Description:
  en: Cross available zone clone and bulky run ECS instance
  zh-cn: the description in Chinese
  name-en: ACS-ECS-CloneInstancesAcrossAZ
  name-zh-cn: the description in Chinese
  categories:
    - cross_region
Parameters:
  regionId:
    Type: String
    Label:
      en: RegionId
      zh-cn: the description in Chinese
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  targets:
    Label:
      en: TargetInstance
      zh-cn: the description in Chinese
    Type: Json
    AssociationProperty: Targets
    AssociationPropertyMetadata:
      ResourceType: 'ALIYUN::ECS::Instance'
      RegionId: regionId
  targetSecurityGroupId:
    Label:
      en: TargetSecurityGroupId
      zh-cn: the description in Chinese
    Type: String
    AssociationProperty: 'ALIYUN::ECS::SecurityGroup::SecurityGroupId'
    AssociationPropertyMetadata:
      RegionId: regionId
  targetVSwitchId:
    Label:
      en: TargetVSwitchId
      zh-cn: the description in Chinese
    Type: String
    AssociationProperty: 'ALIYUN::VPC::VSwitch::VSwitchId'
    AssociationPropertyMetadata:
      RegionId: regionId
      Filters:
        - SecurityGroupId: targetSecurityGroupId
  targetResourceGroupId:
    Label:
      en: TargetResourceGroupId
      zh-cn: the description in Chinese
    Type: String
    Default: ' '
  targetInstanceType:
    Label:
      en: TargetInstanceType
      zh-cn: the description in Chinese
    Type: String
    AssociationProperty: 'ALIYUN::ECS::Instance::InstanceType'
    AssociationPropertyMetadata:
      RegionId: regionId
    Default: ' '
  targetTags:
    Label:
      en: TargetTags
      zh-cn: the description in Chinese
    Type: Json
    AssociationProperty: Tags
    AssociationPropertyMetadata:
      ShowSystem: false
  targetInstanceChargeType:
    Label:
      en: TargetInstanceChargeType
      zh-cn: the description in Chinese
    Type: String
    AllowedValues:
      - PrePaid
      - PostPaid
    Default: PostPaid
  targetPeriodUnit:
    Label:
      en: TargetPeriodUnit
      zh-cn: the description in Chinese
    Type: String
    AllowedValues:
      - Week
      - Month
      - ' '
    Default: ' '
  targetPeriod:
    Label:
      en: TargetPeriod
      zh-cn: the description in Chinese
    Type: Number
    Default: 1
  targetDeploymentSetId:
    Label:
      en: TargetDeploymentSetId
      zh-cn: the description in Chinese
    Type: String
    Default: ' '
  targetInstanceName:
    Label:
      en: TargetInstanceName
      zh-cn: the description in Chinese
    Type: String
    Default: ' '
  targetHostName:
    Label:
      en: TargetHostName
      zh-cn: the description in Chinese
    Type: String
    Default: ' '
  rateControl:
    Label:
      en: RateControl
      zh-cn: the description in Chinese
    Type: Json
    AssociationProperty: RateControl
    Default:
      Mode: Concurrency
      MaxErrors: 0
      Concurrency: 10
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
      zh-cn: the description in Chinese
    Type: String
    Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: getInstance
    Description:
      en: Views the ECS instances
      zh-cn: the description in Chinese
    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: the description in Chinese
    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: the description in Chinese
            en: Configure Parameters
      - Parameters:
          - regionId
          - targets
        Label:
          default:
            zh-cn: the description in Chinese
            en: Select Ecs Instances
      - Parameters:
          - rateControl
          - OOSAssumeRole
        Label:
          default:
            zh-cn: the description in Chinese
            en: Control Options