Template name
ACS-ECS-BulkyDeleteExpiredSnapshot: Deletes expired snapshots in batches.
Template description
Deletes expired snapshots in batches.
Template type
Automation
Owner
Alibaba Cloud
Input parameters
|
Parameter name |
Description |
Type |
Required |
Default value |
Constraints |
|
expiredDays |
The number of days after which snapshots expire. |
Number |
Yes |
||
|
regionId |
The ID of the region. |
String |
No |
{{ ACS::RegionId }} |
|
|
force |
Whether to force-delete the snapshots. |
Boolean |
No |
False |
|
|
snapshotName |
The name used to filter snapshots. |
String |
No |
||
|
tags |
The tags of the snapshots. |
Json |
No |
[] |
|
|
rateControl |
The concurrency rate for task execution. |
Json |
No |
{‘Mode’: ‘Concurrency’, ‘MaxErrors’: 0, ‘Concurrency’: 10} |
|
|
OOSAssumeRole |
The RAM role that OOS assumes. |
String |
No |
“” |
Response parameters
|
Parameter name |
Description |
Type |
|
deletedSnapshotIds |
List |
Access policy required for this template
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:DeleteSnapshot",
"ecs:DescribeSnapshots"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
Details
For more information, see ACS-ECS-BulkyDeleteExpiredSnapshot details.
Template content
FormatVersion: OOS-2019-06-01
Description:
en: Bulky delete expired snapshot
name-en: ACS-ECS-BulkyDeleteExpiredSnapshot
categories:
- data_backup
Parameters:
regionId:
Label:
en: RegionId
Type: String
AssociationProperty: RegionId
Default: '{{ ACS::RegionId }}'
force:
Label:
en: Forced deletion of Snapshot
Type: Boolean
Default: false
expiredDays:
Label:
en: Snapshot Expiration Days
Type: Number
snapshotName:
Label:
en: Name Field Used To Filter Snapshot
Type: String
Default: " "
tags:
Label:
en: Snapshot Tags
Type: Json
AssociationProperty: Tags
AssociationPropertyMetadata:
ShowSystem: false
Default: [ ]
rateControl:
Label:
en: Rate Control
Type: Json
AssociationProperty: RateControl
Default:
Mode: Concurrency
MaxErrors: 0
Concurrency: 10
OOSAssumeRole:
Label:
en: OOSAssumeRole
Type: String
Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: describeSnapshots
Action: 'ACS::ExecuteAPI'
Description:
en: Get the snapshots
Properties:
Service: ECS
API: DescribeSnapshots
Parameters:
RegionId: '{{ regionId }}'
Tags: '{{ tags }}'
Filter2Key: CreationEndTime
Filter2Value:
'Fn::FormatUTCTime':
- 'Fn::AddHour':
- '{{ ACS::CurrentUTCTime }}'
- "Fn::Eval":
- '-{{ expiredDays }}*24'
- '%Y-%m-%dT00:00Z'
Outputs:
snapshotIds:
Type: List
ValueSelector: '.Snapshots.Snapshot[] | select( .SnapshotName | test("{{snapshotName}}")) | .SnapshotId'
- Name: deleteSnapshots
Action: 'ACS::ExecuteAPI'
Description:
en: Delete the snapshots
Properties:
Service: ECS
API: DeleteSnapshot
Parameters:
RegionId: '{{ regionId }}'
SnapshotId: '{{ ACS::TaskLoopItem }}'
Force: '{{ force }}'
Loop:
Items: '{{ describeSnapshots.snapshotIds }}'
RateControl: '{{ rateControl }}'
Outputs:
deletedSnapshotIds:
Type: List
Value: '{{ describeSnapshots.snapshotIds }}'
Metadata:
ALIYUN::OOS::Interface:
ParameterGroups:
- Parameters:
- regionId
- expiredDays
- snapshotName
- tags
- force
Label:
default:
en: Configure Parameters
- Parameters:
- rateControl
- OOSAssumeRole
Label:
default:
en: Control Options