Template name
ACS-ECS-BulkyDeleteSnapshot: Batch delete snapshots
Template description
Deletes multiple snapshots at a time.
Template type
Automated
Owner
Alibaba Cloud
Input parameters
Parameter | Description | Type | Required | Default value | Limit |
snapshotType | The snapshot type. | String | No | Specified | |
snapshotIds | Snapshot ID | List | No | [] | |
force | Specifies whether to forcibly delete the snapshots that have been used to create disks. | Boolean | No | False | |
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
None
Permission policy that is required to execute the template
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:CancelAutoSnapshotPolicy",
"ecs:DeleteImage",
"ecs:DeleteSnapshot",
"ecs:DeleteSnapshotGroup",
"ecs:DescribeAutoSnapshotPolicyEx",
"ecs:DescribeDisks",
"ecs:DescribeImageSharePermission",
"ecs:DescribeImages",
"ecs:DescribeRegions",
"ecs:DescribeSnapshotGroups",
"ecs:DescribeSnapshots",
"ecs:ModifyImageSharePermission"
],
"Resource": "*",
"Effect": "Allow"
},
{
"Action": [
"resourcesharing:DisassociateResourceShare",
"resourcesharing:ListSharedResources"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
Details
For more information, see ACS-ECS-BulkyDeleteSnapshot.yml at GitHub.
Template content
FormatVersion: OOS-2019-06-01
Description:
en: Bulky delete snapshot
zh-cn: Deletes multiple snapshots.
name-en: ACS-ECS-BulkyDeleteSnapshot
name-zh-cn: Batch-Delete-Snapshots
categories:
- data_backup
Parameters:
snapshotType:
Label:
en: SnapshotType
zh-cn: Snapshot Type
Description:
en: 'Specified: Specified snapshot, Unrelated: Unrelated snapshot'
zh-cn: 'Specified: specified snapshots. Unrelated: unassociated snapshots.'
Type: String
Default: Specified
AllowedValues:
- Specified
- Unrelated
snapshotIds:
Label:
en: SnapshotIds
zh-cn: Snapshot IDs
Type: List
AssociationPropertyMetadata:
Visible:
Condition:
Fn::Equals:
- ${snapshotType}
- Specified
Default: []
force:
Label:
en: Force
zh-cn: Force Delete Snapshots Associated with Disks
Type: Boolean
Default: false
rateControl:
Label:
en: RateControl
zh-cn: Task Execution Concurrency Rate
Type: Json
AssociationProperty: RateControl
Default:
Mode: Concurrency
MaxErrors: 0
Concurrency: 10
OOSAssumeRole:
Label:
en: OOSAssumeRole
zh-cn: RAM Role for OOS
Type: String
Default: ''
RamRole: '{{ OOSAssumeRole }}'
Conditions:
SpecifiedSnapshot:
Fn::Equals:
- '{{ snapshotType }}'
- Specified
UnrelatedSnapshot:
Fn::Equals:
- '{{ snapshotType }}'
- Unrelated
Tasks:
- Name: deleteSnapshot
Action: ACS::ExecuteAPI
When: SpecifiedSnapshot
Description:
en: Delete the specified snapshot
zh-cn: Deletes the specified snapshots.
Properties:
Service: ECS
API: DeleteSnapshot
Parameters:
Force: '{{ force }}'
SnapshotId: '{{ ACS::TaskLoopItem }}'
Loop:
RateControl: '{{ rateControl }}'
Items: '{{ snapshotIds }}'
- Name: deleteUnrelatedSnapshot
Action: ACS::ECS::DeleteUnrelatedSnapshots
When: UnrelatedSnapshot
Description:
en: Delete the unrelated snapshot
zh-cn: Deletes the unassociated snapshots.
Properties:
rateControl: '{{ rateControl }}'
Metadata:
ALIYUN::OOS::Interface:
ParameterGroups:
- Parameters:
- snapshotType
- snapshotIds
- force
Label:
default:
zh-cn: Configure Parameters
en: Configure Parameters
- Parameters:
- rateControl
- OOSAssumeRole
Label:
default:
zh-cn: Control Options
en: Control Options