-
Notifications
You must be signed in to change notification settings - Fork 17
/
ACS::ECS::DeleteUnrelatedSnapshots.json
103 lines (103 loc) · 2.64 KB
/
ACS::ECS::DeleteUnrelatedSnapshots.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
{
"FormatVersion": "OOS-2019-06-01",
"Description": {
"en": "Delete unrelated snapshots",
"zh-cn": "删除用户账号下所有无关联的快照",
"name-en": "ACS::ECS::DeleteUnrelatedSnapshots",
"name-zh-cn": "删除用户账号下所有无关联的快照"
},
"Parameters": {
"rateControl": {
"Label": {
"en": "RateControl",
"zh-cn": "任务执行的并发比率"
},
"Type": "Json",
"AssociationProperty": "RateControl"
}
},
"Tasks": [
{
"Name": "getRegionIds",
"Action": "ACS::ExecuteApi",
"Description": {
"en": "Get region id list",
"zh-cn": "获取地域ID列表"
},
"Properties": {
"Service": "ECS",
"API": "DescribeRegions",
"Parameters": {}
},
"Outputs": {
"regionIds": {
"Type": "List",
"ValueSelector": ".Regions.Region[].RegionId"
}
}
},
{
"Name": "getSnapshotIds",
"Action": "ACS::ExecuteApi",
"Description": {
"en": "Get snapshot id list",
"zh-cn": "获取快照ID列表"
},
"Properties": {
"Service": "ECS",
"API": "DescribeSnapshots",
"Parameters": {
"RegionId": "{{ ACS::TaskLoopItem }}"
}
},
"Outputs": {
"snapshotIds": {
"Type": "List",
"ValueSelector": ".Snapshots.Snapshot | map(select(.Usage != \"image\" and .Usage != \"image_disk\" and all(.Tags.Tag[]?; .TagKey != \"acs:ecs:isShared\") and all(.Tags.Tag[]?; .TagKey != \"acs:ecs:sharedFrom\")) | .SnapshotId) | .[]"
}
},
"Loop": {
"RateControl": "{{ rateControl }}",
"Items": "{{ GetRegionIds.regionIds }}",
"Outputs": {
"snapshotIdList": {
"AggregateType": "Fn::ListJoin",
"AggregateField": "snapshotIds"
}
}
}
},
{
"Name": "deleteSnapshots",
"Action": "ACS::ExecuteApi",
"Description": {
"em": "Delete snapshots",
"zh-cn": "删除快照"
},
"Properties": {
"Service": "ECS",
"API": "DeleteSnapshot",
"Parameters": {
"SnapshotId": "{{ ACS::TaskLoopItem }}",
"Force": true
}
},
"Loop": {
"RateControl": "{{ rateControl }}",
"Items": {
"Fn::Jq": [
"First",
"map(select(. != null)) | [.[][]]",
"{{ GetSnapshotIds.snapshotIdList }}"
]
}
}
}
],
"Outputs": {
"deletedSnapshotIdList": {
"Type": "List",
"Value": "{{ GetSnapshotIds.snapshotIdList }}"
}
}
}