Template name
ACS-ECS-BulkyCreateAndExportImage - Creates and exports images in a batch to an OSS bucket
Template description
Creates images for multiple Elastic Compute Service (ECS) instances at a time and exports the images to an Object Storage Service (OSS) bucket.
Template type
Automated
Owner
Alibaba Cloud
Input parameters
Parameter | Description | Type | Required | Default value | Limit |
targets | Target instance | Json | Yes | ||
OSSBucket | The OSS bucket to which the images are to be exported. | String | Yes | ||
tags | The tags of the images. | Json | No | [] | |
rateControl | Concurrent task execution rate | Json | No | {'Mode': 'Concurrency', 'MaxErrors': 0, 'Concurrency': 10} | |
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:DescribeImages",
"ecs:DescribeInstances",
"ecs:ExportImage"
],
"Resource": "*",
"Effect": "Allow"
},
{
"Action": [
"oos:GetApplicationGroup"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
Details
For more information, see ACS-ECS-BulkyCreateAndExportImage.yml at GitHub.
Template content
FormatVersion: OOS-2019-06-01
Description:
en: Batch creates and exports ECS images to an OSS bucket.
zh-cn: Batch creates and exports ECS images to an OSS bucket.
name-en: ACS-ECS-BatchCreateAndExportImage
name-zh-cn: ACS-ECS-BatchCreateAndExportImage
categories:
- image_manage
Parameters:
targets:
Type: Json
Label:
en: Target Instance
zh-cn: Target Instance
AssociationProperty: Targets
AssociationPropertyMetadata:
ResourceType: ALIYUN::ECS::Instance
OSSBucket:
Label:
en: The OSS bucket for storing exported images.
zh-cn: The OSS bucket for storing exported images.
Type: String
tags:
Label:
en: Image Tags
zh-cn: Image Tags
Type: Json
AssociationProperty: Tags
AssociationPropertyMetadata:
ShowSystem: false
Default: []
rateControl:
Label:
en: Concurrency rate for the task execution.
zh-cn: Concurrency rate for the task execution.
Type: Json
AssociationProperty: RateControl
Default:
Mode: Concurrency
MaxErrors: 0
Concurrency: 10
OOSAssumeRole:
Label:
en: The RAM role that OOS assumes.
zh-cn: The RAM role that OOS assumes.
Type: String
Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: getInstance
Description:
en: Retrieves the ECS instances.
zh-cn: Retrieves the ECS instances.
Action: ACS::SelectTargets
Properties:
ResourceType: ALIYUN::ECS::Instance
Filters:
- '{{ targets }}'
Outputs:
instanceIds:
Type: List
ValueSelector: Instances.Instance[].InstanceId
- Name: createImage
Action: ACS::ECS::CreateImage
Description:
en: Creates a new image with the specified image name and instance ID.
zh-cn: Creates a new image with the specified image name and instance ID.
Properties:
instanceId: '{{ ACS::TaskLoopItem }}'
tags: '{{tags}}'
imageName: 'image_of_{{ ACS::TaskLoopItem }}_{{ ACS::ExecutionId }}'
Loop:
Items: '{{ getInstance.instanceIds }}'
RateControl: '{{ rateControl }}'
Outputs:
imageIds:
AggregateType: 'Fn::ListJoin'
AggregateField: imageId
Outputs:
imageId:
ValueSelector: imageId
Type: String
- Name: importImageToOSS
Action: ACS::ExecuteApi
Description:
en: Exports the image to an OSS bucket.
zh-cn: Exports the image to an OSS bucket.
Properties:
Service: ECS
API: ExportImage
Parameters:
ImageId: '{{ ACS::TaskLoopItem }}'
OSSBucket: '{{ OSSBucket }}'
Loop:
Items: '{{ createImage.imageIds }}'
RateControl: '{{ rateControl }}'
Outputs:
imageIds:
Type: List
Value: '{{ createImage.imageIds }}'
Metadata:
ALIYUN::OOS::Interface:
ParameterGroups:
- Parameters:
- targets
- OSSBucket
- tags
Label:
default:
zh-cn: Configure Parameters
en: Configure Parameters
- Parameters:
- rateControl
- OOSAssumeRole
Label:
default:
zh-cn: Advanced Options
en: Advanced Options