Template name
ACS-ECS-BulkyReplaceSystemDisk: Replaces the system disks of ECS instances in batches
Template description
Replaces the system disks of multiple Elastic Compute Service (ECS) instances in a batch. This template is useful for scenarios such as system upgrades and fault recovery. During configuration, you must specify the following required parameters: `regionId` to specify the region of the ECS instances, `imageId` to specify the image for the new system disk, and `targets` to specify the target ECS instances. After the template is executed, it returns a list of the new system disk IDs. You can use this list to verify the status of the disk replacements.
Template type
Automated
Owner
Alibaba Cloud
Input parameters
Parameter | Description | Type | Required | Default value | Limit |
imageId | The image ID. | String | Yes | ||
targets | Target instance | Json | Yes | ||
regionId | The region ID. | String | No | {{ ACS::RegionId }} | |
password | The username and password that are used to access the ECS instance. | String | No | "" | |
keyPairName | The name of the key pair. | String | No | "" | |
rateControl | Task execution concurrency | 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 |
newSystemDiskIds | String |
Permission policy that is required to execute the template
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:DescribeDisks",
"ecs:DescribeInstances",
"ecs:ReplaceSystemDisk",
"ecs:StartInstance",
"ecs:StopInstance"
],
"Resource": "*",
"Effect": "Allow"
},
{
"Action": [
"oos:GetApplicationGroup"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
Details
For more information, see AACS-ECS-BulkyReplaceSystemDisk.yml at GitHub.
Template content
If the system disk capacity of the image you select is larger than the original system disk capacity, the system disk will be automatically expanded, which may incur additional costs.
Description:
en: 'Replaces the system disks of multiple ECS instances in batches. This template is useful for scenarios such as system upgrades and fault recovery. During configuration, provide the required parameters: Region ID (regionId) to specify the region of the ECS instances, Image ID (imageId) to specify the image for the new system disk, and Target Instances (targets) to define the specific ECS instances. After execution, the template returns a list of the new system disk IDs to help you verify the replacement status.'
name-en: ACS-ECS-BulkyReplaceSystemDisk
categories:
- instance_manage
- application_management
- tag_operate_resource
Parameters:
regionId:
Type: String
Label:
en: RegionId
AssociationProperty: RegionId
Default: '{{ ACS::RegionId }}'
imageId:
Label:
en: ImageId
Description:
en: <div>If the system disk capacity of the image you select is larger than the original system disk capacity, the system disk is automatically expanded. This may incur additional costs. </div>
Type: String
AssociationProperty: 'ALIYUN::ECS::Image::ImageId'
AssociationPropertyMetadata:
RegionId: regionId
password:
Label:
en: Password
Type: String
Default: ''
keyPairName:
Label:
en: KeyPairName
Type: String
Default: ''
targets:
Type: Json
Label:
en: TargetInstance
AssociationProperty: Targets
AssociationPropertyMetadata:
ResourceType: 'ALIYUN::ECS::Instance'
RegionId: regionId
rateControl:
Label:
en: RateControl
Type: Json
AssociationProperty: RateControl
Default:
Mode: Concurrency
MaxErrors: 0
Concurrency: 10
OOSAssumeRole:
Label:
en: OOSAssumeRole
Type: String
Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: getInstance
Description:
en: Gets the specified ECS instances
Action: 'ACS::SelectTargets'
Properties:
ResourceType: 'ALIYUN::ECS::Instance'
RegionId: '{{ regionId }}'
Filters:
- '{{ targets }}'
Outputs:
instanceIds:
Type: List
ValueSelector: 'Instances.Instance[].InstanceId'
- Name: replaceSystemDisk
Action: 'ACS::ECS::ReplaceSystemDisk'
Description:
en: Replaces the system disk
Properties:
regionId: '{{ regionId }}'
instanceId: '{{ ACS::TaskLoopItem }}'
imageId: '{{ imageId }}'
keyPairName: '{{ keyPairName }}'
password: '{{ password }}'
Loop:
RateControl: '{{ rateControl }}'
Items: '{{ getInstance.instanceIds }}'
Outputs:
newSystemDiskIds:
AggregateType: 'Fn::ListJoin'
AggregateField: newSystemDiskId
Outputs:
newSystemDiskId:
Type: String
ValueSelector: newSystemDiskId
Outputs:
newSystemDiskIds:
Type: String
Value: '{{ replaceSystemDisk.newSystemDiskIds }}'
Metadata:
ALIYUN::OOS::Interface:
ParameterGroups:
- Parameters:
- imageId
- password
- keyPairName
Label:
default:
en: Configure Parameters
- Parameters:
- regionId
- targets
Label:
default:
en: Select ECS Instances
- Parameters:
- rateControl
- OOSAssumeRole
Label:
default:
en: Advanced Options