ACS-ECS-CloneInstancesAcrossRegion
更新時間:
模板名稱
ACS-ECS-CloneInstancesAcrossRegion 跨地域克隆ECS實例
模板描述
跨地域克隆ECS實例
模板類型
自動化
所有者
Alibaba Cloud
輸入?yún)?shù)
參數(shù)名稱 | 描述 | 類型 | 是否必填 | 默認值 | 約束 |
instanceIds | ECS實例ID列表 | List | 是 | ||
regionId | 源地域ID | String | 是 | 最大長度 : 30 最小長度 : 1 | |
targetRegionId | 目標地域ID | String | 是 | 最大長度 : 30 最小長度 : 1 | |
targetZoneId | 目標可用區(qū)ID | String | 是 | 最大長度 : 30 最小長度 : 1 | |
targetInstanceType | 實例類型 | String | 是 | 字符串校驗正則表達式 : ecs.[A-Za-z0-9.-]* 最大長度 : 30 最小長度 : 1 | |
targetSecurityGroupId | 安全組ID | String | 是 | 字符串校驗正則表達式 : sg-[A-Za-z0-9]* 最大長度 : 30 最小長度 : 1 | |
targetVSwitchId | 交換機ID | String | 是 | 字符串校驗正則表達式 : vsw-[A-Za-z0-9]* 最大長度 : 30 最小長度 : 1 | |
OOSAssumeRole | OOS扮演的RAM角色 | String | 否 | “” |
輸出參數(shù)
參數(shù)名稱 | 描述 | 類型 |
instanceIds | List |
執(zhí)行此模板需要的權(quán)限策略
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:CopyImage",
"ecs:CreateImage",
"ecs:DescribeDisks",
"ecs:DescribeImages",
"ecs:DescribeInstances",
"ecs:RunInstances"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
詳情
ACS-ECS-CloneInstancesAcrossRegion詳情
模板內(nèi)容
FormatVersion: OOS-2019-06-01
Description:
en: Cross Region copy and run ECS instance by InstanceIds
zh-cn: 跨地域克隆ECS實例
title: ACS-ECS-CloneInstancesAcrossRegion
name-en: ACS-ECS-CloneInstancesAcrossRegion
name-zh-cn: 跨地域克隆ECS實例
categories:
- cross_region
Parameters:
instanceIds:
Label:
en: InstanceIds
zh-cn: ECS實例ID列表
Type: List
regionId:
Label:
en: RegionId
zh-cn: 源地域ID
Type: String
MinLength: 1
MaxLength: 30
targetRegionId:
Label:
en: TargetRegionId
zh-cn: 目標地域ID
Type: String
MinLength: 1
MaxLength: 30
targetZoneId:
Label:
en: TargetZoneId
zh-cn: 目標可用區(qū)ID
Type: String
MinLength: 1
MaxLength: 30
targetInstanceType:
Label:
en: TargetInstanceType
zh-cn: 實例類型
Type: String
AllowedPattern: 'ecs\.[A-Za-z0-9\.\-]*'
MinLength: 1
MaxLength: 30
targetSecurityGroupId:
Label:
en: TargetSecurityGroupId
zh-cn: 安全組ID
Type: String
AllowedPattern: 'sg-[A-Za-z0-9]*'
MinLength: 1
MaxLength: 30
targetVSwitchId:
Label:
en: TargetVSwitchId
zh-cn: 交換機ID
Type: String
AllowedPattern: 'vsw-[A-Za-z0-9]*'
MinLength: 1
MaxLength: 30
OOSAssumeRole:
Label:
en: OOSAssumeRole
zh-cn: OOS扮演的RAM角色
Type: String
Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: queryDisks
Action: ACS::ExecuteAPI
Description:
en: Views disk info of the ECS instance
zh-cn: 查看實例的磁盤信息
Properties:
Service: ECS
API: DescribeDisks
Parameters:
RegionId: '{{ regionId }}'
InstanceId: '{{ ACS::TaskLoopItem }}'
Outputs:
instanceDataDisks:
Type: Json
ValueSelector: '.Disks.Disk|map( select(.Type == "data" )|{"Category":(.Category),"Device": (.Device),"Size":(.Size),"DiskName":(.DiskName),"PerformanceLevel":(.PerformanceLevel)})'
instanceSystemDisk:
Type: Json
ValueSelector: '.Disks.Disk|map( select(.Type == "system" )|{"Category":(.Category),"Device": (.Device),"Size":(.Size),"DiskName":(.DiskName),"PerformanceLevel":(.PerformanceLevel)})[]'
Loop:
Items: '{{ instanceIds }}'
Outputs:
dataDisks:
AggregateType: 'Fn::ListJoin'
AggregateField: instanceDataDisks
systemDisks:
AggregateType: 'Fn::ListJoin'
AggregateField: instanceSystemDisk
- Name: createImage
Action: 'ACS::ExecuteAPI'
Description:
en: Create Image
zh-cn: 創(chuàng)建鏡像
Properties:
Service: ECS
API: CreateImage
Parameters:
RegionId: '{{ regionId }}'
ImageName: 'img-{{ ACS::TaskLoopItem }}-{{ACS::ExecutionId}}'
InstanceId: '{{ ACS::TaskLoopItem }}'
DetectionStrategy: Standard
Loop:
Items: '{{ instanceIds }}'
Outputs:
ImageIds:
AggregateType: 'Fn::ListJoin'
AggregateField: ImageId
Outputs:
ImageId:
ValueSelector: ImageId
Type: String
- Name: untilCreateImageReady
Action: 'ACS::WaitFor'
Description:
en: Wait For created images available
zh-cn: 等待鏡像創(chuàng)建成功
Properties:
Service: ECS
API: DescribeImages
Parameters:
RegionId: '{{ regionId }}'
ImageId: '{{ ACS::TaskLoopItem }}'
DesiredValues:
- Available
PropertySelector: 'Images.Image[].Status'
Loop:
Items: '{{ createImage.ImageIds }}'
Retries: 57
- Name: copyImage
Action: 'ACS::ExecuteAPI'
Description:
en: Copy image
zh-cn: 復(fù)制鏡像
Properties:
Service: ECS
API: CopyImage
Parameters:
RegionId: '{{ regionId }}'
ImageId: '{{ ACS::TaskLoopItem }}'
DestinationRegionId: '{{ targetRegionId }}'
Loop:
Items: '{{ createImage.ImageIds }}'
Outputs:
ImageIds:
AggregateType: 'Fn::ListJoin'
AggregateField: ImageId
Outputs:
ImageId:
ValueSelector: ImageId
Type: String
- Name: untilCopyImageReady
Action: 'ACS::WaitFor'
Description:
en: Wait for copied images available
zh-cn: 等待鏡像復(fù)制成功
Properties:
Service: ECS
API: DescribeImages
Parameters:
RegionId: '{{ targetRegionId }}'
ImageId: '{{ ACS::TaskLoopItem }}'
DesiredValues:
- Available
PropertySelector: 'Images.Image[].Status'
Loop:
Items: '{{ copyImage.ImageIds }}'
- Name: runInstances
Action: 'ACS::ExecuteAPI'
Description:
en: run instances
zh-cn: 創(chuàng)建實例
Properties:
Service: ECS
API: RunInstances
Parameters:
RegionId: '{{ targetRegionId }}'
ZoneId: '{{ targetZoneId }}'
ImageId:
'Fn::Select':
- '{{ ACS::TaskLoopItem }}'
- '{{ copyImage.ImageIds }}'
DataDisks:
'Fn::Select':
- '{{ ACS::TaskLoopItem }}'
- '{{queryDisks.dataDisks}}'
SystemDiskCategory:
'Fn::Select':
- Category
- 'Fn::Select':
- '{{ ACS::TaskLoopItem }}'
- '{{ queryDisks.systemDisks }}'
SystemDiskSize:
'Fn::Select':
- Size
- 'Fn::Select':
- '{{ ACS::TaskLoopItem }}'
- '{{ queryDisks.systemDisks }}'
SystemDiskDiskName:
'Fn::Select':
- DiskName
- 'Fn::Select':
- '{{ ACS::TaskLoopItem }}'
- '{{ queryDisks.systemDisks }}'
SystemDiskPerformanceLevel:
'Fn::Select':
- PerformanceLevel
- 'Fn::Select':
- '{{ ACS::TaskLoopItem }}'
- '{{ queryDisks.systemDisks }}'
InstanceType: '{{ targetInstanceType }}'
SecurityGroupId: '{{ targetSecurityGroupId }}'
VSwitchId: '{{ targetVSwitchId }}'
Loop:
Items:
'Fn::Jq':
- All
- '.|length|range(.)'
- '{{ instanceIds }}'
Outputs:
instanceIds:
AggregateType: 'Fn::ListJoin'
AggregateField: instanceId
Outputs:
instanceId:
Type: String
ValueSelector: 'InstanceIdSets.InstanceIdSet[]'
- Name: untilInstanceReady
Action: 'ACS::WaitFor'
Description:
en: Wait for instances running
zh-cn: 等待實例創(chuàng)建成功
Properties:
Service: ECS
API: DescribeInstances
Parameters:
RegionId: '{{ targetRegionId }}'
InstanceIds: '{{ runInstances.instanceIds }}'
DesiredValues:
- Running
PropertySelector: '.Instances.Instance[].Status'
Outputs:
instanceIds:
Value: '{{ runInstances.instanceIds }}'
Type: List
Metadata:
ALIYUN::OOS::Interface:
ParameterGroups:
- Parameters:
- targetRegionId
- targetZoneId
- targetInstanceType
- targetSecurityGroupId
- targetVSwitchId
Label:
default:
zh-cn: 設(shè)置參數(shù)
en: Configure Parameters
- Parameters:
- regionId
- instanceIds
Label:
default:
zh-cn: 選擇實例
en: Select Ecs Instances
- Parameters:
- OOSAssumeRole
Label:
default:
zh-cn: 高級選項
en: Control Options
文檔內(nèi)容是否對您有幫助?