Template name
ACS-ECS-BulkyCloneInstances
Template description
Clones multiple Elastic Compute Service (ECS) instances at a time. Take note of the following items:
Before you clone instances, make sure that all the required drivers are installed on the source instances. Otherwise, the cloned instances may fail to start.
The clone process is implemented based on images and snapshots. If you want to retain the all data of source instances in cloned instances, including the data that is generated during cloning, set the IncrementSnapshot parameter to True. If you do not want to retain the data that is generated during cloning, set the IncrementSnapshot parameter to False. We recommend that you set the IncrementSnapshot to False first and test whether your business can run as expected on the cloned instances. If your business runs as expected on the cloned instances, you can set the IncrementSnapshot parameter to True to migrate all data.
The amount of time that is required to create a snapshot is within minutes, and varies based on the size of the disk. The first snapshot that is created for a disk is a full snapshot. The amount of time that is required to create a full snapshot may be a few hours. Subsequent snapshots that are created for the disk are incremental snapshots. It takes longer to create a full snapshot than an incremental snapshot. The amount of time that is required to create an incremental snapshot varies based on the amount of data changed since the previous snapshot. As the amount of modified data increases, the amount of time that is required to create an incremental snapshot increases.
Make sure that disks can be automatically attached to the instances. Otherwise, disks fail to be attached to the instances when the instances are restarted after migration.
The clone operation is a high-risk operation. If you set the IncrementSnapshot parameter to true, make sure that the impacts of instance shutdown on your business are controllable.
You need to manually associate public IP addresses and elastic IP addresses (EIPs) with the cloned instances. For more information, see Convert the system-assigned public IP address of an instance in the classic network into an EIP, Convert the public IP address of an ECS instance in a VPC to an EIP, and Modify the private IP address of an instance.
You can create snapshots for the source instances before you execute the template. This can accelerate the execution.
Make sure that your account balance is sufficient to purchase the cloned instances.
Template type
Automated
Owner
Alibaba Cloud
Input parameters
Parameter | Description | Type | Required | Default value | Limit |
instanceIds | The ECS instances to be cloned. | List | Yes | ||
targetZoneId | The zone ID of the cloned ECS instances. | String | Yes | ||
targetInstanceChargeType | The billing method of the cloned ECS instances. | String | Yes | ||
targetInstanceType | The instance type of the cloned ECS instances. | String | Yes | ||
targetVPCId | The virtual private network (VPC) ID of the cloned ECS instances. | String | Yes | ||
targetVSwitchId | The vSwitch ID of the cloned ECS instances. | String | Yes | ||
targetSecurityGroupIds | The IDs of security groups to which the cloned ECS instances are added. | List | Yes | ||
targetSystemDiskCategory | The category of the system disk. | String | Yes | ||
targetDataDiskCategory | The category of the data disk. | String | Yes | ||
targetPassword | The password that is used to access the cloned ECS instances. | String | Yes | Regular expression for string verification: [0-9A-Za-z_-&:;'<>,=%`~!@#()$^*+|{}[].?/]+$ The value must be 8 to 30 characters in length.
| |
regionId | The region in which the ECS instances to be cloned reside. | String | No | {{ ACS::RegionId }} | |
targetPeriodUnit | The unit of the subscription duration. | String | No | Month | |
targetPeriod | The subscription duration. | Number | No | 1 | |
useIncrementSnapshot | Specifies whether to stop the source ECS instances and create incremental snapshots. | Boolean | No | False | |
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: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"
}
]
}
References
For more information, see ACS-ECS-BulkyCloneInstances.yml at GitHub.
Template content
FormatVersion: OOS-2019-06-01
Description:
en: <p class="p">Clone ECS instances in batches. Note:</p> <ul class="ul"> <li class="li">Please check for missing drivers before migrating, so as not to cause the new instance to fail to start. </li> <li class="li">Based on mirror snapshot migration, if you need to retain complete data, please select <font color='blue'>Incremental snapshots for downtime</font> as Yes, and then go to the next step; if you do not need to retain data generated during the migration process, select No and migrate directly according to the guidelines. <font color='red'>It is recommended that you select No to test whether the new instance is normal, and then select Yes to ensure complete data. </font></li> <li class="li">The time required to create a snapshot is in minutes and depends on the size of the cloud disk. The first snapshot of the cloud disk is a full snapshot, which takes a long time and may be at the hour level. Creating a snapshot again takes a relatively short time, but still depends on the amount of data changes since the last snapshot. The bigger the change, the longer it will take. </li> <li class="li"><font color='red'>Because the machine will restart, please make sure that the data disk has been set to be automatically mounted. Ootherwise, the data disk will not be mounted after restarting. </font></li> <li class="li"><font color='red'>The current operation is a high-risk operation. If you select Yes for snapshot migration, please confirm that the business impact of the shutdown is controllable. </font></li> <li class="li"><font color='red'>Public IP and Elastic IP need to be manually re-bound to the new instance. Refer to the documentation: <a href='https://help.aliyun.com/document_detail/156287.html'>Classic network type ECS public IP is converted to elastic public IP</a>, <a href='https://help.aliyun.com/document_detail/67455.html'>Convert the fixed public IP of the VPC ECS instance to EIP</a>, <a href='https://help.aliyun.com/document_detail/27733.html'>Modify private IP address</a></font></li> <li class="li">Take a snapshot of the instance before execution, which will greatly shorten the execution time. </li> <li class="li"><font color='red'>Please make sure that your account balance is greater than the cost of the newly purchased instance. </font></li> </ul>
zh-cn: the description in Chinese </font></li> </ul>
name-en: ACS-ECS-BulkyCloneInstances
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 }}'
instanceIds:
Label:
en: InstanceIds
zh-cn: the description in Chinese
Type: List
AssociationProperty: ALIYUN::ECS::Instance::InstanceId
AssociationPropertyMetadata:
RegionId: regionId
targetZoneId:
Label:
en: TargetZoneId
zh-cn: the description in Chinese
Description:
en: For more instance purchase information, please refer to the ECS purchase page
zh-cn: the description in Chinese
Type: String
AssociationProperty: ALIYUN::ECS::Instance::ZoneId
AssociationPropertyMetadata:
RegionId: regionId
targetInstanceChargeType:
Label:
en: TargetInstanceChargeType
zh-cn: the description in Chinese
Type: String
AssociationProperty: ChargeType
targetPeriodUnit:
Label:
en: The unit of the subscription period
zh-cn: the description in Chinese
Type: String
AssociationPropertyMetadata:
Visible:
Condition:
'Fn::Not':
'Fn::Equals':
- '${targetInstanceChargeType}'
- PostPaid
AllowedValues:
- Week
- Month
Default: Month
targetPeriod:
Label:
en: TargetPeriod
zh-cn: the description in Chinese
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: the description in Chinese
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 description in Chinese
Type: String
AssociationProperty: ALIYUN::ECS::Instance::InstanceType
AssociationPropertyMetadata:
RegionId: regionId
ZoneId: targetZoneId
InstanceChargeType: targetInstanceChargeType
targetVPCId:
Label:
en: TargetVPCId
zh-cn: the description in Chinese
Type: String
AssociationProperty: ALIYUN::ECS::VPC::VPCId
AssociationPropertyMetadata:
RegionId: regionId
targetVSwitchId:
Label:
en: TargetVSwitchId
zh-cn: the description in Chinese
Description:
en: Please confirm whether the switch is in the selected zone. If not, please reselect or create a new switch
zh-cn: the description in Chinese
Type: String
AssociationProperty: ALIYUN::VPC::VSwitch::VSwitchId
AssociationPropertyMetadata:
RegionId: regionId
ZoneId: targetZoneId
VpcId: targetVPCId
targetSecurityGroupIds:
Label:
en: TargetSecurityGroupIds
zh-cn: the description in Chinese
Description:
en: The vSwitch and the security group must belong to the same VPC
zh-cn: the description in Chinese
Type: List
AssociationProperty: ALIYUN::ECS::SecurityGroup::SecurityGroupId
AssociationPropertyMetadata:
RegionId: regionId
VpcId: targetVPCId
targetSystemDiskCategory:
Label:
en: TargetSystemDiskCategory
zh-cn: the description in Chinese
Type: String
AssociationProperty: ALIYUN::ECS::Disk::SystemDiskCategory
AssociationPropertyMetadata:
RegionId: regionId
ZoneId: targetZoneId
InstanceType: targetInstanceType
InstanceChargeType: targetInstanceChargeType
targetDataDiskCategory:
Label:
en: TargetDataDiskCategory
zh-cn: the description in Chinese
Type: String
AssociationProperty: ALIYUN::ECS::Disk::DataDiskCategory
AssociationPropertyMetadata:
RegionId: regionId
ZoneId: targetZoneId
InstanceType: targetInstanceType
InstanceChargeType: targetInstanceChargeType
targetPassword:
Label:
en: TargetPassword
zh-cn: the description in Chinese
Description:
en: "<font color='red'><b>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.</b></font>Special characters include: ()`~!@#$%^&*-_+=|{}[]:;''<>,.?/ Passwords of Windows instances cannot start with a forward slash (/)."
zh-cn: the description in Chinese
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, in order to ensure data consistency to the greatest extent, the system will stop the source instance after the full snapshot (downtime charging mode), create an incremental snapshot, create a destination instance based on the incremental snapshot and start it run. <font color='red'>If the task is successfully executed, the source instance will remain in the down state. You can manually release it as soon as possible after verifying that the business of the destination instance is normal to avoid repeated charges. </font>If the task fails, restart the source instance. </li> <li class="li">If you select No (the default is No), in order to ensure that the source machine is always available, the system will create the destination instance based on the full snapshot and start it after the full snapshot. <font color='red'>But the incremental data after the task is started will not be synchronized to the destination instance, which may cause data inconsistency, please be aware. </font></li></ul>
zh-cn: the description in Chinese </font></li></ul>
Label:
en: IncrementSnapshot
zh-cn: the description in Chinese
Default: false
OOSAssumeRole:
Label:
en: OOSAssumeRole
zh-cn: the description in Chinese
Type: String
Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: cloneInstances
Action: ACS::ECS::CloneInstance
Description:
en: Clone ECS instances
zh-cn: the description in Chinese
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 with increment snapshot
zh-cn: the description in Chinese
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: the description in Chinese
en: Select Instances
- Parameters:
- targetZoneId
- targetInstanceChargeType
- targetPeriodUnit
- targetPeriod
- targetInstanceType
- targetVPCId
- targetVSwitchId
- targetSecurityGroupIds
- targetSystemDiskCategory
- targetDataDiskCategory
- targetPassword
Label:
default:
zh-cn: the description in Chinese
en: Configure Parameters
- Parameters:
- useIncrementSnapshot
Label:
default:
en: IncrementSnapshot
zh-cn: the description in Chinese
- Parameters:
- OOSAssumeRole
Label:
default:
zh-cn: the description in Chinese
en: Control Options