模板名称
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 }}'
文档内容是否对您有帮助?