Template name
ACS-ECS-BulkyCreateAndExportImage
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 | The ECS instances for which you want to create images. | 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 | The rate control settings. | 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"
}
]
}
References
For more information, see ACS-ECS-BulkyCreateAndExportImage.yml at GitHub.
Template content
FormatVersion: OOS-2019-06-01
Description:
en: Bulky creates ECS image and exports them into OSS
zh-cn: the description in Chinese
name-en: ACS-ECS-BulkyCreateAndExportImage
name-zh-cn: the description in Chinese
categories:
- image_manage
Parameters:
targets:
Type: Json
Label:
en: TargetInstance
zh-cn: the description in Chinese
AssociationProperty: Targets
AssociationPropertyMetadata:
ResourceType: ALIYUN::ECS::Instance
OSSBucket:
Label:
en: OSSBucket
zh-cn: the description in Chinese
Type: String
tags:
Label:
en: Tags
zh-cn: the description in Chinese
Type: Json
AssociationProperty: Tags
AssociationPropertyMetadata:
ShowSystem: false
Default: []
rateControl:
Label:
en: RateControl
zh-cn: the description in Chinese
Type: Json
AssociationProperty: RateControl
Default:
Mode: Concurrency
MaxErrors: 0
Concurrency: 10
OOSAssumeRole:
Label:
en: OOSAssumeRole
zh-cn: the description in Chinese
Type: String
Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: getInstance
Description:
en: Views the ECS instances
zh-cn: the description in Chinese
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: Create new image with the specified image name and instance ID
zh-cn: the description in Chinese
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: EXport image to OSS bucket
zh-cn: the description in Chinese
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: the description in Chinese
en: Configure Parameters
- Parameters:
- rateControl
- OOSAssumeRole
Label:
default:
zh-cn: the description in Chinese
en: Control Options