模板名稱
ACS-ESS-UpdateScalingConfigurationImage 更新彈性伸縮配置鏡像
模板描述
通過運行命令更新一個已存在的ECS鏡像后創建一個新ECS鏡像并更新伸縮配置中的鏡像ID
模板類型
自動化
所有者
Alibaba Cloud
輸入參數
參數名稱 | 描述 | 類型 | 是否必填 | 默認值 | 約束 |
sourceImageId | 源鏡像ID | String | 是 | ||
securityGroupId | 安全組ID | String | 是 | ||
vSwitchId | 交換機ID | String | 是 | ||
commandContent | 云助手命令 | String | 是 | ||
scalingConfigurationIds | 待修改的伸縮配置ID列表 | List | 是 | ||
regionId | 地域ID | String | 否 | {{ ACS::RegionId }} | |
targetImageName | 新鏡像的名稱 | String | 否 | UpdateImage_from_{{ sourceImageId }}on{{ ACS::ExecutionId }} | |
instanceType | ECS實例類型 | String | 否 | ecs.g5.large | 字符串校驗正則表達式 : ecs.[A-Za-z0-9.-]* |
commandType | 云助手命令類型 | String | 否 | RunShellScript | |
tags | 鏡像標簽 | Json | 否 | [] | |
OOSAssumeRole | OOS扮演的RAM角色 | String | 否 | "" |
輸出參數
參數名稱 | 描述 | 類型 |
imageId | String |
執行此模板需要的權限策略
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:CreateImage",
"ecs:DeleteInstance",
"ecs:DescribeCloudAssistantStatus",
"ecs:DescribeImages",
"ecs:DescribeInstances",
"ecs:DescribeInvocationResults",
"ecs:DescribeInvocations",
"ecs:InstallCloudAssistant",
"ecs:RebootInstance",
"ecs:RunCommand",
"ecs:RunInstances",
"ecs:StopInstance"
],
"Resource": "*",
"Effect": "Allow"
},
{
"Action": [
"ess:ModifyScalingConfiguration"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
詳情
ACS-ESS-UpdateScalingConfigurationImage詳情
模板內容
FormatVersion: OOS-2019-06-01
Description:
en: Updates an existing ECS image via ECS Cloud Assistant then creates an ECS image and updates scaling configuration image ID
zh-cn: 通過運行命令更新一個已存在的ECS鏡像后創建一個新ECS鏡像并更新伸縮配置中的鏡像ID
name-en: ACS-ESS-UpdateScalingConfigurationImage
name-zh-cn: 更新彈性伸縮配置鏡像
categories:
- elastic_manage
Parameters:
regionId:
Type: String
Label:
en: RegionId
zh-cn: 地域ID
AssociationProperty: RegionId
Default: '{{ ACS::RegionId }}'
targetImageName:
Label:
en: NewImageName
zh-cn: 新鏡像的名稱
Type: String
Default: UpdateImage_from_{{ sourceImageId }}_on_{{ ACS::ExecutionId }}
sourceImageId:
Label:
en: SourceImageId
zh-cn: 源鏡像ID
Type: String
AssociationProperty: 'ALIYUN::ECS::Image::ImageId'
AssociationPropertyMetadata:
RegionId: regionId
instanceType:
Label:
en: InstanceType
zh-cn: ECS實例類型
Type: String
AssociationProperty: 'ALIYUN::ECS::Instance::InstanceType'
AllowedPattern: ecs\.[A-Za-z0-9\.\-]*
Default: 'ecs.g5.large'
securityGroupId:
Label:
en: SecurityGroupId
zh-cn: 安全組ID
Type: String
AssociationProperty: 'ALIYUN::ECS::SecurityGroup::SecurityGroupId'
AssociationPropertyMetadata:
RegionId: regionId
vSwitchId:
Label:
en: VSwitchId
zh-cn: 交換機ID
Type: String
AssociationProperty: 'ALIYUN::VPC::VSwitch::VSwitchId'
AssociationPropertyMetadata:
RegionId: regionId
Filters:
- SecurityGroupId: securityGroupId
commandType:
Label:
en: CommandType
zh-cn: 云助手命令類型
Type: String
AllowedValues:
- RunBatScript
- RunPowerShellScript
- RunShellScript
Default: RunShellScript
commandContent:
Label:
en: CommandContent
zh-cn: 云助手命令
Type: String
AssociationProperty: Code
scalingConfigurationIds:
Label:
en: ScalingConfigurationIds
zh-cn: 待修改的伸縮配置ID列表
Type: List
tags:
Label:
en: ImageTags
zh-cn: 鏡像標簽
Type: Json
AssociationProperty: Tags
AssociationPropertyMetadata:
ShowSystem: false
Default: []
OOSAssumeRole:
Label:
en: OOSAssumeRole
zh-cn: OOS扮演的RAM角色
Type: String
Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: checkNewImageName
Action: ACS::CheckFor
Description:
en: Check image name is available
zh-cn: 檢查鏡像名稱是可用的
Properties:
Service: ECS
API: DescribeImages
Parameters:
RegionId: '{{ regionId }}'
ImageName: '{{ targetImageName }}'
DesiredValues:
- 0
PropertySelector: TotalCount
- Name: runInstances
Action: ACS::ECS::RunInstances
Description:
en: Create a ECS instance with source image
zh-cn: 用源鏡像創建一臺ECS實例
Properties:
regionId: '{{ regionId }}'
imageId: '{{ sourceImageId }}'
instanceType: '{{ instanceType }}'
securityGroupId: '{{ securityGroupId }}'
vSwitchId: '{{ vSwitchId }}'
Outputs:
instanceId:
ValueSelector: instanceIds[0]
Type: String
- Name: installCloudAssistant
Action: ACS::ECS::InstallCloudAssistant
Description:
en: Install cloud assostant for ECS instance
zh-cn: 給實例安裝云助手
OnError: deleteInstance
Properties:
regionId: '{{ regionId }}'
instanceId: '{{ runInstances.instanceId }}'
- Name: runCommand
Action: ACS::ECS::RunCommand
Description:
en: Run cloud assostant command on ECS instance
zh-cn: 在實例中運行云助手命令
OnError: deleteInstance
Properties:
regionId: '{{ regionId }}'
commandContent: '{{ commandContent }}'
commandType: '{{ commandType }}'
instanceId: '{{ runInstances.instanceId }}'
- Name: stopInstance
Action: ACS::ECS::StopInstance
Description:
en: Stops the ECS instance
zh-cn: 停止ECS實例
Properties:
regionId: '{{ regionId }}'
instanceId: '{{ runInstances.instanceId }}'
- Name: createImage
Action: ACS::ECS::CreateImage
Description:
en: Create new image with the specified image name and instance ID
zh-cn: 通過指定實例ID和鏡像名稱創建新的鏡像
OnError: deleteInstance
Properties:
regionId: '{{ regionId }}'
imageName: '{{ targetImageName }}'
instanceId: '{{ runInstances.instanceId }}'
tags: '{{tags}}'
Outputs:
imageId:
ValueSelector: imageId
Type: String
- Name: deleteInstance
Action: ACS::ExecuteAPI
Description:
en: Deletes the ECS instance
zh-cn: 刪除ECS實例
Properties:
Service: ECS
API: DeleteInstance
Risk: Normal
Parameters:
RegionId: '{{ regionId }}'
InstanceId: '{{ runInstances.instanceId }}'
Force: true
- Name: modifyScalingConfiguration
Action: ACS::ExecuteAPI
Description:
en: Modify scaling configuration
zh-cn: 修改伸縮配置
Properties:
Service: ESS
API: ModifyScalingConfiguration
Parameters:
RegionId: '{{ regionId }}'
ScalingConfigurationId: '{{ ACS::TaskLoopItem }}'
ImageId: '{{ createImage.imageId }}'
Loop:
Items: '{{ scalingConfigurationIds }}'
Outputs:
imageId:
Type: String
Value: '{{ createImage.imageId }}'
文檔內容是否對您有幫助?