All Products
Search
Document Center

CloudOps Orchestration Service:ACS-ECS-BulkyCloneInstances

Last Updated:Jun 03, 2026

Template name

ACS-ECS-BulkyCloneInstances: Clone ECS instances in batches

Run now

Description

Clones ECS instances in batches by creating image snapshots. Note:

  • Before migration, check for missing drivers to prevent new instances from failing to start.

  • To preserve all data, set "Create incremental snapshots for stopped instances" to Yes. If data generated during migration is not needed, set to No. Test with No first; after confirming the new instances work, run again with Yes for complete data integrity.

  • Snapshot creation time depends on disk size. The first full snapshot may take hours. Incremental snapshots are faster but depend on data changed since the last snapshot.

  • Instances restart during this process. Ensure data disks are set to auto-attach; otherwise they will not be attached after restart.

  • This is a risky operation. If you use shutdown snapshot migration, confirm the business impact is acceptable.

  • You must manually re-attach public IP addresses and EIPs to the new instances: Convert the public IP address of a classic network ECS instance to an EIP, Convert the static public IP address of a VPC ECS instance to an EIP, and Primary private IP address.

  • Pre-creating snapshots greatly reduces template execution time.

  • Ensure sufficient account balance to cover the cost of new instances.

Template type

Automation

Owner

Alibaba Cloud

Input parameters

Parameter name

Description

Type

Required

Default value

Constraints

instanceIds

ECS instance IDs to clone.

List

Yes

targetZoneId

Target zone for the cloned instances.

String

Yes

targetInstanceChargeType

Billing method for new instances.

String

Yes

targetInstanceType

Instance type for cloned instances.

String

Yes

targetVPCId

Target VPC.

String

Yes

targetVSwitchId

Target vSwitch.

String

Yes

targetSecurityGroupIds

Target security group.

List

Yes

targetSystemDiskCategory

System disk category.

String

Yes

targetDataDiskCategory

Data disk category.

String

Yes

targetPassword

Login password for the new instances.

String

Yes

String validation regular expression: [0-9A-Za-z_-&:;’<>,=%`~!@#()$^*+|{}[].?/]+$

Maximum length: 30

Minimum length: 8|

regionId

Region of source ECS instances.

String

No

{{ ACS::RegionId }}

targetPeriodUnit

Unit of the subscription duration.

String

No

Month

targetPeriod

Subscription duration.

Number

No

1

useIncrementSnapshot

Whether to create incremental snapshots for stopped instances.

Boolean

No

False

OOSAssumeRole

RAM role for OOS to assume.

String

No

“”

Output parameters

Parameter name

Description

Type

instanceIds

List

Permissions required to run this template

{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "ecs:CreateImage",
                "ecs:CreateSnapshot",
                "ecs:DeleteImage",
                "ecs:DeleteSnapshot",
                "ecs:DescribeAvailableResource",
                "ecs:DescribeDisks",
                "ecs:DescribeImages",
                "ecs:DescribeInstances",
                "ecs:DescribeSnapshots",
                "ecs:DescribeVSwitches",
                "ecs:RunInstances",
                "ecs:StartInstance",
                "ecs:StopInstance"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}

Details

ACS-ECS-BulkyCloneInstances details

Template content

FormatVersion: OOS-2019-06-01
Description:
  en: <p class="p">Clones Elastic Compute Service (ECS) instances in batches. Note:</p> <ul class="ul"> <li class="li">Before migration, check for missing drivers to prevent the new instances from failing to start.</li> <li class="li">This template uses image snapshots for migration. To keep all data, set <font color='blue'>Create incremental snapshots for stopped instances</font> to Yes. If you do not need to keep data generated during the migration, set it to No. <font color='red'>Set it to No first to test if the new instances work correctly. After you confirm the new instances are working, run the template again with the setting as Yes to ensure complete data integrity.</font></li> <li class="li">Creating a snapshot takes several minutes, depending on the disk size. The first snapshot of a disk is a full snapshot and can take a long time, possibly hours. Subsequent snapshots are faster but still depend on the amount of data changed since the last snapshot. More changes mean a longer creation time.</li> <li class="li"><font color='red'>The instances will restart. Ensure that data disks are set to automatically attach. Otherwise, the data disks will not be attached after the restart.</font></li> <li class="li"><font color='red'>This is a risky operation. If you set "Create incremental snapshots for stopped instances" to Yes, confirm that the business impact of stopping the instances is acceptable.</font></li> <li class="li"><font color='red'>You must manually re-attach public IP addresses and Elastic IP Addresses (EIPs) to the new instances. For more information, see <a href='https://www.alibabacloud.com/help/document_detail/156287.html'>Convert the public IP address of a classic network ECS instance to an EIP</a>, <a href='https://www.alibabacloud.com/help/document_detail/67455.html'>Convert the static public IP address of a VPC ECS instance to an EIP</a>, and <a href='https://www.alibabacloud.com/help/document_detail/27733.html'>Modify a private IP address</a>.</font></li> <li class="li">Creating a snapshot of the instances before running the template greatly reduces the running time.</li> <li class="li"><font color='red'>Ensure your account balance is sufficient to cover the cost of the new instances.</font></li> </ul>
  zh-cn: <p class="p">Clones Elastic Compute Service (ECS) instances in batches. Note:</p> <ul class="ul"> <li class="li">Before migration, check for missing drivers to prevent the new instances from failing to start.</li> <li class="li">This template uses image snapshots for migration. To keep all data, set <font color='blue'>Create incremental snapshots for stopped instances</font> to Yes. If you do not need to keep data generated during the migration, set it to No. <font color='red'>Set it to No first to test if the new instances work correctly. After you confirm the new instances are working, run the template again with the setting as Yes to ensure complete data integrity.</font></li> <li class="li">Creating a snapshot takes several minutes, depending on the disk size. The first snapshot of a disk is a full snapshot and can take a long time, possibly hours. Subsequent snapshots are faster but still depend on the amount of data changed since the last snapshot. More changes mean a longer creation time.</li> <li class="li"><font color='red'>The instances will restart. Ensure that data disks are set to automatically attach. Otherwise, the data disks will not be attached after the restart.</font></li> <li class="li"><font color='red'>This is a risky operation. If you set "Create incremental snapshots for stopped instances" to Yes, confirm that the business impact of stopping the instances is acceptable.</font></li> <li class="li"><font color='red'>You must manually re-attach public IP addresses and Elastic IP Addresses (EIPs) to the new instances. For more information, see <a href='https://www.alibabacloud.com/help/document_detail/156287.html'>Convert the public IP address of a classic network ECS instance to an EIP</a>, <a href='https://www.alibabacloud.com/help/document_detail/67455.html'>Convert the static public IP address of a VPC ECS instance to an EIP</a>, and <a href='https://www.alibabacloud.com/help/document_detail/27733.html'>Modify a private IP address</a>.</font></li> <li class="li">Creating a snapshot of the instances before running the template greatly reduces the running time.</li> <li class="li"><font color='red'>Ensure your account balance is sufficient to cover the cost of the new instances.</font></li> </ul>
  name-en: ACS-ECS-BulkyCloneInstances
  name-zh-cn: Clone ECS instances in batches
  categories:
    - cross_region
Parameters:
  regionId:
    Type: String
    Label:
      en: RegionId
      zh-cn: The region of the ECS instances to clone.
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  instanceIds:
    Label:
      en: InstanceIds
      zh-cn: The ECS instances to clone.
    Type: List
    AssociationProperty: ALIYUN::ECS::Instance::InstanceId
    AssociationPropertyMetadata:
      RegionId: regionId
  targetZoneId:
    Label:
      en: TargetZoneId
      zh-cn: The zone.
    Description:
      en: For more information about purchasing instances, see the ECS purchase page: https://ecs-buy.alibabacloud.com/
      zh-cn: For more information about purchasing instances, see the ECS purchase page: https://ecs-buy.alibabacloud.com/
    Type: String
    AssociationProperty: ALIYUN::ECS::Instance::ZoneId
    AssociationPropertyMetadata:
      RegionId: regionId
  targetInstanceChargeType:
    Label:
      en: TargetInstanceChargeType
      zh-cn: The billing method.
    Type: String
    AssociationProperty: ChargeType
  targetPeriodUnit:
    Label:
      en: The unit of the subscription period
      zh-cn: The unit of the subscription duration.
    Type: String
    AssociationPropertyMetadata:
      Visible:
        Condition:
          'Fn::Not':
            'Fn::Equals':
              - '${targetInstanceChargeType}'
              - PostPaid
    AllowedValues:
      - Week
      - Month
    Default: Month
  targetPeriod:
    Label:
      en: TargetPeriod
      zh-cn: The subscription duration.
    Description:
      en: "Valid values:
          Valid values when PeriodUnit is set to Week: 1, 2, 3, and 4.
          Valid values when PeriodUnit is set to Month: 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 24, 36, 48, and 60."
      zh-cn: "Valid values:
          When PeriodUnit is Week, valid values for Period are: 1, 2, 3, 4.
          When PeriodUnit is Month, valid values for Period are: 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 24, 36, 48, 60."
    Type: Number
    AssociationPropertyMetadata:
      Visible:
        Condition:
          'Fn::Not':
            'Fn::Equals':
              - '${targetInstanceChargeType}'
              - PostPaid
    AllowedValues:
      - 1
      - 2
      - 3
      - 4
      - 5
      - 6
      - 7
      - 8
      - 9
      - 12
      - 24
      - 36
      - 48
      - 60
    Default: 1
  targetInstanceType:
    Label:
      en: TargetInstanceType
      zh-cn: The instance type.
    Type: String
    AssociationProperty: ALIYUN::ECS::Instance::InstanceType
    AssociationPropertyMetadata:
      RegionId: regionId
      ZoneId: targetZoneId
      InstanceChargeType: targetInstanceChargeType
  targetVPCId:
    Label:
      en: TargetVPCId
      zh-cn: The virtual private cloud (VPC).
    Type: String
    AssociationProperty: ALIYUN::ECS::VPC::VPCId
    AssociationPropertyMetadata:
      RegionId: regionId
  targetVSwitchId:
    Label:
      en: TargetVSwitchId
      zh-cn: The vSwitch.
    Description:
      en: Confirm that the vSwitch is in the selected zone. If not, reselect or create a new vSwitch.
      zh-cn: Confirm that the vSwitch is in the selected zone. If not, reselect or create a new vSwitch.
    Type: String
    AssociationProperty: ALIYUN::VPC::VSwitch::VSwitchId
    AssociationPropertyMetadata:
      RegionId: regionId
      ZoneId: targetZoneId
      VpcId: targetVPCId
  targetSecurityGroupIds:
    Label:
      en: TargetSecurityGroupIds
      zh-cn: The security group.
    Description:
      en: The vSwitch and the security group must belong to the same VPC.
      zh-cn: The security group and the vSwitch must be in the same VPC.
    Type: List
    AssociationProperty: ALIYUN::ECS::SecurityGroup::SecurityGroupId
    AssociationPropertyMetadata:
      RegionId: regionId
      VpcId: targetVPCId
  targetSystemDiskCategory:
    Label:
      en: TargetSystemDiskCategory
      zh-cn: The category of the system disk.
    Type: String
    AssociationProperty: ALIYUN::ECS::Disk::SystemDiskCategory
    AssociationPropertyMetadata:
      RegionId: regionId
      ZoneId: targetZoneId
      InstanceType: targetInstanceType
      InstanceChargeType: targetInstanceChargeType
  targetDataDiskCategory:
    Label:
      en: TargetDataDiskCategory
      zh-cn: The category of the data disk.
    Type: String
    AssociationProperty: ALIYUN::ECS::Disk::DataDiskCategory
    AssociationPropertyMetadata:
      RegionId: regionId
      ZoneId: targetZoneId
      InstanceType: targetInstanceType
      InstanceChargeType: targetInstanceChargeType
  targetPassword:
    Label:
      en: TargetPassword
      zh-cn: The instance password.
    Description:
      en: "<font color='red'>The password must be 8 to 30 characters in length and include at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters.</font>Special characters include the following: ()`~!@#$%^&*-_+=|{}[]:;''<>,.?/  Passwords of Windows instances cannot start with a forward slash (/)."
      zh-cn: "<font color='red'>The password must be 8 to 30 characters long and contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters.</font> Special characters can be: ()`~!@#$%^&*-_+=|{}[]:;'<>,.?/. The password of a Windows instance cannot start with a forward slash (/)."
    Type: String
    AllowedPattern: '[0-9A-Za-z\_\-\&:;''<>,=%`~!@#\(\)\$\^\*\+\|\{\}\[\]\.\?\/]+$'
    MinLength: 8
    MaxLength: 30
    NoEcho: true
  useIncrementSnapshot:
    Type: Boolean
    Description:
      en: <p class="p">Note:</p><ul class="ul"> <li class="li">If you select Yes, to ensure maximum data consistency, the system stops the source instance (in a stopped but billing state) after the full snapshot is created. Then, it creates an incremental snapshot, creates the destination instance from the incremental snapshot, and starts the destination instance. <font color='red'>If the task succeeds, the source instance remains stopped. Manually release the source instance as soon as possible after you verify that the destination instance is working correctly to avoid further charges.</font> If the task fails, the source instance is restarted.</li> <li class="li">If you select No (the default), to ensure the source instance is always available, the system creates and starts the destination instance from the full snapshot. <font color='red'>However, incremental data generated after the task starts is not synchronized to the destination instance. This may cause data inconsistency.</font></li></ul>
      zh-cn: <p class="p">Note:</p><ul class="ul"> <li class="li">If you select Yes, to ensure maximum data consistency, the system stops the source instance (in a stopped but billing state) after the full snapshot is created. Then, it creates an incremental snapshot, creates the destination instance from the incremental snapshot, and starts the destination instance. <font color='red'>If the task succeeds, the source instance remains stopped. Manually release the source instance as soon as possible after you verify that the destination instance is working correctly to avoid further charges.</font> If the task fails, the source instance is restarted.</li> <li class="li">If you select No (the default), to ensure the source instance is always available, the system creates and starts the destination instance from the full snapshot. <font color='red'>However, incremental data generated after the task starts is not synchronized to the destination instance. This may cause data inconsistency.</font></li></ul>
    Label:
      en: Create incremental snapshots for stopped instances
      zh-cn: Create incremental snapshots for stopped instances
    Default: false
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
      zh-cn: The RAM role that OOS assumes.
    Type: String
    Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: cloneInstances
    Action: ACS::ECS::CloneInstance
    Description:
      en: Clone ECS instances
      zh-cn: Clone ECS instances
    When:
      'Fn::Equals':
        - '{{ useIncrementSnapshot }}'
        - false
    Properties:
      regionId: '{{ regionId }}'
      imageName: img-{{ ACS::TaskLoopItem }}-{{ACS::ExecutionId}}
      instanceId: '{{ ACS::TaskLoopItem }}'
      targetVSwitchId: '{{ targetVSwitchId }}'
      targetInstanceType: '{{ targetInstanceType }}'
      targetSecurityGroupIds: '{{ targetSecurityGroupIds }}'
      targetPassword: '{{ targetPassword }}'
      targetInstanceChargeType: '{{ targetInstanceChargeType }}'
      targetPeriodUnit: '{{ targetPeriodUnit }}'
      targetPeriod: '{{ targetPeriod }}'
      targetSystemDiskCategory: '{{ targetSystemDiskCategory }}'
      targetDataDiskCategory: '{{ targetDataDiskCategory }}'
    Loop:
      Items: '{{ instanceIds }}'
      RateControl:
        Mode: Concurrency
        MaxErrors: 0
        Concurrency: 10
      Outputs:
        instanceIds:
          AggregateType: Fn::ListJoin
          AggregateField: instanceId
    Outputs:
      instanceId:
        Type: String
        ValueSelector: instanceId
  - Name: cloneInstancesWithIncrementSnapshot
    Action: ACS::ECS::CloneInstanceWithIncrementSnapshot
    Description:
      en: Clone ECS instances using incremental snapshots
      zh-cn: Clone ECS instances using incremental snapshots
    When:
      'Fn::Equals':
        - '{{ useIncrementSnapshot }}'
        - true
    Properties:
      regionId: '{{ regionId }}'
      imageName: img-{{ ACS::TaskLoopItem }}-{{ACS::ExecutionId}}
      instanceId: '{{ ACS::TaskLoopItem }}'
      targetVSwitchId: '{{ targetVSwitchId }}'
      targetInstanceType: '{{ targetInstanceType }}'
      targetSecurityGroupIds: '{{ targetSecurityGroupIds }}'
      targetPassword: '{{ targetPassword }}'
      targetInstanceChargeType: '{{ targetInstanceChargeType }}'
      targetPeriodUnit: '{{ targetPeriodUnit }}'
      targetPeriod: '{{ targetPeriod }}'
      targetSystemDiskCategory: '{{ targetSystemDiskCategory }}'
      targetDataDiskCategory: '{{ targetDataDiskCategory }}'
    Loop:
      Items: '{{ instanceIds }}'
      RateControl:
        Mode: Concurrency
        MaxErrors: 0
        Concurrency: 10
      Outputs:
        instanceIds:
          AggregateType: Fn::ListJoin
          AggregateField: instanceId
    Outputs:
      instanceId:
        Type: String
        ValueSelector: instanceId
Outputs:
  instanceIds:
    Type: List
    Value:
      Fn::If:
        - 'Fn::Equals':
            - '{{ useIncrementSnapshot }}'
            - true
        - '{{ cloneInstancesWithIncrementSnapshot.instanceIds }}'
        - '{{ cloneInstances.instanceIds }}'
Metadata:
  ALIYUN::OOS::Interface:
    ParameterGroups:
      - Parameters:
          - regionId
          - instanceIds
        Label:
          default:
            zh-cn: Select Instances
            en: Select Instances
      - Parameters:
          - targetZoneId
          - targetInstanceChargeType
          - targetPeriodUnit
          - targetPeriod
          - targetInstanceType
          - targetVPCId
          - targetVSwitchId
          - targetSecurityGroupIds
          - targetSystemDiskCategory
          - targetDataDiskCategory
          - targetPassword
        Label:
          default:
            zh-cn: Configure Parameters
            en: Configure Parameters
      - Parameters:
          - useIncrementSnapshot
        Label:
          default:
            en: Incremental Snapshot Option
            zh-cn: Incremental Snapshot Option
      - Parameters:
          - OOSAssumeRole
        Label:
          default:
            zh-cn: Advanced Options
            en: Advanced Options