Template name
ACS-ECS-CreateImageAndUpdateLaunchTemplates
Template description
Creates an Elastic Compute Service (ECS) image and updates a list of launch templates.
Template type
Automated
Owner
Alibaba Cloud
Input parameters
Parameter | Description | Type | Required | Default value | Limit |
instanceId | The ID of the ECS instance. | String | Yes | ||
regionId | The region ID. | String | No | {{ ACS::RegionId }} | |
targetImageName | The name of the image to be created. | String | No | CreateImage_from_{{instanceId}} | |
launchTemplateNames | The list of launch template names to be updated. | List | No | [] | |
tags | The tags of the image. | Json | No | [] | |
deleteSourceTemplateVersion | Specifies whether to delete the original version of the launch templates. | Boolean | No | True | |
rateControl | The rate control settings. | Json | No | {'Mode': 'Concurrency', 'MaxErrors': '0', 'Concurrency': 5} | |
OOSAssumeRole | The Resource Access Management (RAM) role that is assumed by CloudOps Orchestration Service (OOS). | String | No | "" |
Output parameters
Parameter | Description | Type |
imageIds | List |
Permission policy that is required to execute the template
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:CreateImage",
"ecs:CreateLaunchTemplateVersion",
"ecs:DeleteLaunchTemplateVersion",
"ecs:DescribeDisks",
"ecs:DescribeImages",
"ecs:DescribeInstances",
"ecs:DescribeLaunchTemplateVersions",
"ecs:DescribeLaunchTemplates",
"ecs:ModifyLaunchTemplateDefaultVersion"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
References
For more information, see ACS-ECS-CreateImageAndUpdateLaunchTemplates.yml at GitHub.
Template content
FormatVersion: OOS-2019-06-01
Description:
name-en: ACS-ECS-CreateImageAndUpdateLaunchTemplates
name-zh-cn: the description in Chinese
en: Creates an ECS image and update launch template
zh-cn: the description in Chinese
categories:
- image_manage
Parameters:
regionId:
Type: String
Label:
en: RegionId
zh-cn: the description in Chinese
AssociationProperty: RegionId
Default: '{{ ACS::RegionId }}'
instanceId:
Label:
en: InstanceId
zh-cn: the description in Chinese
Type: String
AssociationProperty: ALIYUN::ECS::Instance::InstanceId
AssociationPropertyMetadata:
RegionId: regionId
targetImageName:
Label:
en: TargetImageName
zh-cn: the description in Chinese
Type: String
Description:
en: <p class="p">Note:</p> <ul class="ul"> <li class="li">Length is 2~128 English or Chinese characters</li> <li class="li"><font color='red'>must start with big or small letters or Chinese, not http:// and https://. </font></li> <li class="li">Can contain numbers, colons (:), underscores (_), or dashes (-). </li> </ul>
zh-cn: the description in Chinese </li> </ul>
Default: CreateImage_from_{{instanceId}}
launchTemplateNames:
Description:
en: <font color='red'><b>Must correspond to the selected region</b></font>
zh-cn: the description in Chinese
Label:
en: LaunchTemplateNames
zh-cn: the description in Chinese
Type: List
Default: []
tags:
Label:
en: Tags
zh-cn: the description in Chinese
Type: Json
AssociationProperty: Tags
AssociationPropertyMetadata:
ShowSystem: false
Default: []
deleteSourceTemplateVersion:
Label:
en: DeleteSourceTemplateVersion
zh-cn: the description in Chinese
Type: Boolean
Default: true
rateControl:
Label:
en: RateControl
zh-cn: the description in Chinese
Type: Json
AssociationProperty: RateControl
Default:
Mode: Concurrency
MaxErrors: 0
Concurrency: 5
OOSAssumeRole:
Label:
en: OOSAssumeRole
zh-cn: the description in Chinese
Type: String
Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: createImage
Action: 'ACS::ECS::CreateImage'
Description:
en: Create new image with the specified image name and instance ID
zh-cn: the description in Chinese
Properties:
regionId: '{{ regionId }}'
instanceId: '{{ instanceId }}'
imageName: '{{ targetImageName }}_on_{{ ACS::ExecutionId }}_at_{{ Acs::CurrentDate }}'
tags: '{{tags}}'
Outputs:
imageId:
ValueSelector: imageId
Type: String
- Name: describeDisks
Action: 'ACS::ExecuteAPI'
Description:
en: Get disk info of the ECS instance
zh-cn: the description in Chinese
Properties:
Service: ECS
API: DescribeDisks
Parameters:
RegionId: '{{ regionId }}'
InstanceId: '{{ instanceId }}'
Outputs:
systemDiskSize:
Type: String
ValueSelector: '.Disks.Disk[] | select(.Type == "system" )|.Size'
systemDiskPerformanceLevel:
Type: String
ValueSelector: '.Disks.Disk[] | select(.Type == "system" )|.PerformanceLevel'
systemDiskDeleteWithInstance:
Type: Boolean
ValueSelector: '.Disks.Disk[] | select(.Type == "system" )|.DeleteWithInstance'
- Name: updateLaunchTemplate
Action: 'ACS::ECS::UpdateLaunchTemplate'
Description:
en: Update instance launch template
zh-cn: the description in Chinese
Properties:
regionId: '{{ regionId }}'
imageId: '{{ createImage.imageId }}'
launchTemplateName: '{{ ACS::TaskLoopItem }}'
deleteSourceTemplateVersion: '{{ deleteSourceTemplateVersion }}'
systemDiskSize: '{{ describeDisks.systemDiskSize}}'
systemDiskPerformanceLevel: '{{ describeDisks.systemDiskPerformanceLevel }}'
systemDiskDeleteWithInstance: '{{ describeDisks.systemDiskDeleteWithInstance }}'
Loop:
Items: '{{ launchTemplateNames }}'
Outputs:
imageIds:
Type: List
Value: '{{ createImage.imageId }}'
Metadata:
ALIYUN::OOS::Interface:
ParameterGroups:
- Parameters:
- regionId
- instanceId
Label:
default:
zh-cn: the description in Chinese
en: Select Ecs Instances
- Parameters:
- targetImageName
- tags
Label:
default:
zh-cn: the description in Chinese
en: Image Configure
- Parameters:
- launchTemplateNames
- deleteSourceTemplateVersion
Label:
default:
zh-cn: the description in Chinese
en: Launch Template
- Parameters:
- rateControl
- OOSAssumeRole
Label:
default:
zh-cn: the description in Chinese
en: Control Options