Template name
ACS-ECS-BulkyDeleteExpiredImage
Template description
Deletes multiple expired images at a time.
Template
Automated
Owner
Alibaba Cloud
Input parameters
Parameter | Description | Type | Required | Default value | Limit |
expiredDays | The number of days that have elapsed after the images expired. | Number | Yes | ||
regionId | The region ID. | String | No | {{ ACS::RegionId }} | |
force | Specifies whether to forcibly delete the images. | Boolean | No | False | |
imageName | The name field that is used to filter the images. | String | No | ||
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 |
deletedImageIds | List |
Permission policy that is required to execute the template
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:DeleteImage",
"ecs:DescribeImages"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
References
For more information, see ACS-ECS-BulkyDeleteExpiredImage.yml at GitHub.
Template content
FormatVersion: OOS-2019-06-01
Description:
en: Bulky delete expired image
zh-cn: the description in Chinese
name-en: ACS-ECS-BulkyDeleteExpiredImage
name-zh-cn: the description in Chinese
categories:
- image_manage
Parameters:
regionId:
Label:
en: RegionId
zh-cn: the description in Chinese
Type: String
AssociationProperty: RegionId
Default: '{{ ACS::RegionId }}'
force:
Label:
en: Forced deletion of Image
zh-cn: the description in Chinese
Type: Boolean
Default: false
expiredDays:
Label:
en: Image Expiration Days
zh-cn: the description in Chinese
Type: Number
imageName:
Label:
en: Name Field Used To Filter Images
zh-cn: the description in Chinese
Type: String
Default: " "
tags:
Label:
en: Image Tags
zh-cn: the description in Chinese
Type: Json
AssociationProperty: Tags
AssociationPropertyMetadata:
ShowSystem: false
Default: []
rateControl:
Label:
en: Rate Control
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: describeImages
Action: 'ACS::ExecuteAPI'
Description:
en: Get the images
zh-cn: the description in Chinese
Properties:
Service: ECS
API: DescribeImages
Parameters:
RegionId: '{{ regionId }}'
ImageOwnerAlias: self
Tags: '{{ tags }}'
Filter:
- Key: CreationEndTime
Value:
'Fn::FormatUTCTime':
- 'Fn::AddHour':
- '{{ ACS::CurrentUTCTime }}'
- "Fn::Eval":
- '-{{ expiredDays }}*24'
- '%Y-%m-%dT00:00Z'
Outputs:
imageIds:
Type: List
ValueSelector: '.Images.Image[] | select( .ImageName | test("{{imageName}}")) | .ImageId'
- Name: deleteImages
Action: 'ACS::ExecuteAPI'
Description:
en: Delete the images
zh-cn: the description in Chinese
Properties:
Service: ECS
API: DeleteImage
Parameters:
RegionId: '{{ regionId }}'
ImageId: '{{ ACS::TaskLoopItem }}'
Force: '{{ force }}'
Loop:
Items: '{{ describeImages.imageIds }}'
RateControl: '{{ rateControl }}'
Outputs:
deletedImageIds:
Type: List
Value: '{{ describeImages.imageIds }}'
Metadata:
ALIYUN::OOS::Interface:
ParameterGroups:
- Parameters:
- regionId
- expiredDays
- imageName
- tags
- force
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