Template name
ACS-ECS-CreateImageAndUpdateLaunchTemplates: creates an ECS image from a specified instance and updates the specified launch templates with the new image.
Description
Creates an ECS image from a specified instance and updates the specified launch templates with the new image.
Template type
Automation
Owner
Alibaba Cloud
Input parameters
|
Parameter name |
Description |
Type |
Required |
Default value |
Constraints |
|
instanceId |
The ECS instance ID. |
String |
Yes |
||
|
regionId |
The region ID. |
String |
No |
{{ ACS::RegionId }} |
|
|
targetImageName |
The image name. |
String |
No |
CreateImage_from_{{instanceId}} |
|
|
launchTemplateNames |
The launch template names to update. |
List |
No |
[] |
|
|
tags |
The image tags. |
JSON |
No |
[] |
|
|
deleteSourceTemplateVersion |
Specifies whether to delete the previous version of the launch template. |
Boolean |
No |
True |
|
|
rateControl |
The concurrency settings for task execution. |
Json |
No |
{‘Mode’: ‘Concurrency’, ‘MaxErrors’: 0, ‘Concurrency’: 5} |
|
|
OOSAssumeRole |
The RAM role assumed by OOS to run the template. |
String |
No |
“” |
Output parameters
|
Parameter name |
Description |
Type |
|
imageIds |
List |
Permissions 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"
}
]
}
Details
Details for ACS-ECS-CreateImageAndUpdateLaunchTemplates
Template content
FormatVersion: OOS-2019-06-01
Description:
name-en: ACS-ECS-CreateImageAndUpdateLaunchTemplates
en: Creates an ECS image and updates a launch template.
categories:
- image_manage
Parameters:
regionId:
Type: String
Label:
en: Region ID
AssociationProperty: RegionId
Default: '{{ ACS::RegionId }}'
instanceId:
Label:
en: Instance ID
Type: String
AssociationProperty: ALIYUN::ECS::Instance::InstanceId
AssociationPropertyMetadata:
RegionId: regionId
targetImageName:
Label:
en: Target Image Name
Type: String
Description:
en: <p class="p">Note:</p> <ul class="ul"> <li class="li">The name must be 2 to 128 characters in length.</li> <li class="li"><font color='red'>The name must start with a letter or a Chinese character. It cannot start with http:// or https://.</font></li> <li class="li">The name can contain digits, colons (:), underscores (_), and hyphens (-).</li> </ul>
Default: CreateImage_from_{{instanceId}}
launchTemplateNames:
Description:
en: <font color='red'>The launch templates must be in the selected region.</font>
Label:
en: Launch Template Names
Type: List
Default: []
tags:
Label:
en: Image Tags
Type: Json
AssociationProperty: Tags
AssociationPropertyMetadata:
ShowSystem: false
Default: []
deleteSourceTemplateVersion:
Label:
en: Delete Source Template Version
Type: Boolean
Default: true
rateControl:
Label:
en: Rate Control
Type: Json
AssociationProperty: RateControl
Default:
Mode: Concurrency
MaxErrors: 0
Concurrency: 5
OOSAssumeRole:
Label:
en: OOS Assume Role
Type: String
Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: createImage
Action: 'ACS::ECS::CreateImage'
Description:
en: Create a new image from the specified instance ID and image name.
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 the disk information of the ECS instance.
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 the instance launch template.
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:
en: Select ECS Instance
- Parameters:
- targetImageName
- tags
Label:
default:
en: Image Settings
- Parameters:
- launchTemplateNames
- deleteSourceTemplateVersion
Label:
default:
en: Launch Template
- Parameters:
- rateControl
- OOSAssumeRole
Label:
default:
en: Advanced Options