Template name
ACS-ECS-CreateImage
Template description
Creates a custom image from an existing Elastic Compute Service (ECS) instance. This template is useful for scenarios such as instance backup and system migration. During configuration, you must provide the following required parameters: `regionId` to specify the region of the source ECS instance, `instanceId` to identify the source instance, and `imageName` to set the name of the new image. You can also use the `whetherOnlySystemDisk` parameter to specify whether to create an image from only the system disk. After the image is created, the template returns the ID of the new image.
Template type
Automated
Owner
Alibaba Cloud
Input parameters
Parameter | Description | Type | Required | Default value | Limit |
instanceId | The ID of the ECS instance. | String | Yes | ||
imageName | The name of the image to be created. | String | Yes | ||
regionId | The region ID. | String | No | {{ ACS::RegionId }} | |
tags | The tags of the image. | Json | No | [] | |
imageFamily | The image family. | String | No | False | |
imageDescription | The image description. | String | No | "" | |
resourceGroupId | The resource group ID. | String | No | "" | |
detectionStrategy | The image detection strategy. | String | No | "" | |
whetherOnlySystemDisk | Whether to create an image only from the system disk. | Boolean | No | False | |
OOSAssumeRole | The RAM role assumed by OOS. | String | No | "" |
Output parameters
Parameter | Description | Type |
imageId | String |
Permission policy that is required to execute the template
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:CreateImage",
"ecs:CreateSnapshot",
"ecs:DescribeDisks",
"ecs:DescribeImages",
"ecs:DescribeInstances",
"ecs:DescribeSnapshots"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
Details
For more information, see ACS-ECS-CreateImage.yml at GitHub.
Template content
Note:
Description:
en: 'Creates an ECS image from an existing ECS instance. Use this for tasks such as system backup and migration. You must provide the region ID, instance ID, and image name. You can also choose to create an image from only the system disk. The template returns the new image ID after creation.'
zh-cn: 'Creates an ECS image from an existing ECS instance. Use this for tasks such as system backup and migration. You must provide the region ID, instance ID, and image name. You can also choose to create an image from only the system disk. The template returns the new image ID after creation.'
name-en: Create Image
name-zh-cn: Create Image
categories:
- image_manage
- application_manage
Parameters:
regionId:
Type: String
Label:
en: Region ID
zh-cn: Region ID
AssociationProperty: RegionId
Default: '{{ ACS::RegionId }}'
instanceId:
Label:
en: Instance ID
zh-cn: ECS Instance ID
Type: String
AssociationProperty: ALIYUN::ECS::Instance::InstanceId
AssociationPropertyMetadata:
RegionId: regionId
imageName:
Label:
en: Image Name
zh-cn: New Image Name
Type: String
Description:
en: <p>Note:</p> <ul> <li>The name must be 2 to 128 characters in length.</li> <li><font>It must start with a letter or a Chinese character. It cannot start with http:// or https://.</font></li> <li>It can contain numbers, colons (:), underscores (_), and hyphens (-).</li> </ul>
zh-cn: <p>Note:</p> <ul> <li>The name must be 2 to 128 characters in length.</li> <li><font>It must start with a letter or a Chinese character. It cannot start with http:// or https://.</font></li> <li>It can contain numbers, colons (:), underscores (_), and hyphens (-).</li> </ul>
tags:
Label:
en: Tags
zh-cn: Image Tags
Type: Json
AssociationProperty: Tags
AssociationPropertyMetadata:
ShowSystem: false
Default: []
imageFamily:
Label:
en: Image Family
zh-cn: Image Family
Type: String
AssociationProperty: ALIYUN::ECS::Image::ImageFamily
Default: ''
imageDescription:
Label:
en: Image Description
zh-cn: Image Description
Type: String
Default: ''
resourceGroupId:
Label:
en: Resource Group ID
zh-cn: Resource Group ID
Type: String
AssociationProperty: ALIYUN::ECS::ResourceGroup::ResourceGroupId
Default: ''
detectionStrategy:
Label:
en: Detection Strategy
zh-cn: Image Detection Strategy
Type: String
AllowedValues:
- Standard
- ''
Default: ''
whetherOnlySystemDisk:
Label:
en: Create from System Disk Only
zh-cn: Create from System Disk Only
Type: Boolean
Default: false
OOSAssumeRole:
Label:
en: OOS Assume Role
zh-cn: The RAM role for OOS to assume
Type: String
Default: ''
RamRole: '{{ OOSAssumeRole }}'
Conditions:
NotOnlySystemDisk:
Fn::Equals:
- '{{ whetherOnlySystemDisk }}'
- false
OnlySystemDisk:
Fn::Equals:
- '{{ whetherOnlySystemDisk }}'
- true
Tasks:
- Name: createImage
Action: ACS::ECS::CreateImage
Description:
en: Creates a new image with the specified instance ID and image name.
zh-cn: Creates a new image with the specified instance ID and image name.
When: NotOnlySystemDisk
Properties:
regionId: '{{ regionId }}'
imageName: '{{ imageName }}__on_{{ ACS::ExecutionId }}_at_{{ Acs::CurrentDate }}'
instanceId: '{{ instanceId }}'
tags: '{{tags}}'
imageFamily: '{{ imageFamily }}'
imageDescription: '{{ imageDescription }}'
resourceGroupId: '{{ resourceGroupId }}'
detectionStrategy: '{{ detectionStrategy }}'
Outputs:
imageId:
ValueSelector: imageId
Type: String
- Name: createImageOnlySystemDisk
Action: ACS::ECS::CreateImageForSystemDisk
Description:
en: Creates a new system disk image with the specified instance ID and image name.
zh-cn: Creates a new system disk image with the specified instance ID and image name.
When: OnlySystemDisk
Properties:
regionId: '{{ regionId }}'
imageName: '{{ imageName }}__on_{{ ACS::ExecutionId }}_at_{{ Acs::CurrentDate }}'
instanceId: '{{ instanceId }}'
tags: '{{tags}}'
imageFamily: '{{ imageFamily }}'
imageDescription: '{{ imageDescription }}'
resourceGroupId: '{{ resourceGroupId }}'
detectionStrategy: '{{ detectionStrategy }}'
Outputs:
imageId:
ValueSelector: imageId
Type: String
Outputs:
imageId:
Type: String
Value:
Fn::If:
- Fn::Equals:
- '{{ whetherOnlySystemDisk }}'
- false
- '{{ createImage.imageId }}'
- '{{ createImageOnlySystemDisk.imageId }}'
Metadata:
ALIYUN::OOS::Interface:
ParameterGroups:
- Parameters:
- regionId
- instanceId
Label:
default:
zh-cn: Select ECS Instance
en: Select ECS Instance
- Parameters:
- imageName
- tags
- whetherOnlySystemDisk
- imageFamily
- imageDescription
- resourceGroupId
- detectionStrategy
Label:
default:
zh-cn: Image Settings
en: Image Settings
- Parameters:
- OOSAssumeRole
Label:
default:
zh-cn: Advanced Options
en: Advanced Options