-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathACS::ECS::CreateSnapshot.yml
140 lines (140 loc) · 3.8 KB
/
ACS::ECS::CreateSnapshot.yml
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
FormatVersion: OOS-2019-06-01
Description:
name-en: ACS::ECS::CreateSnapshot
name-zh-cn: 为云盘创建快照
en: Creates a snapshot for a disk
zh-cn: 为一块云盘创建一个快照
Parameters:
regionId:
Description:
en: The ID of region
zh-cn: 地域ID
Type: String
Default: '{{ ACS::RegionId }}'
diskId:
Description:
en: The ID of the disk
zh-cn: 云盘ID
Type: String
MinLength: 1
MaxLength: 30
snapshotName:
Description:
en: The name of snapshot
zh-cn: 快照名称
Type: String
Default: ''
retentionDays:
Description:
en: 'The retention period of the snapshot. Valid values: 1 to 65536. Unit: days'
zh-cn: 快照的保留时间,取值范围:1~65536,单位为天
Type: String
Default: ''
tags:
Description:
en: Tags of snapshot
zh-cn: 快照标签
Type: Json
AssociationProperty: Tags
AssociationPropertyMetadata:
ShowSystem: false
Default: []
Tasks:
- Action: 'ACS::ExecuteAPI'
Name: describeDisks
Description:
en: Queries created cloud disks info
zh-cn: 获取已经创建的云盘信息
Properties:
Service: ECS
API: DescribeDisks
Parameters:
RegionId: '{{ regionId }}'
DiskIds:
- '{{ diskId }}'
Outputs:
instanceIds:
Type: List
ValueSelector: 'Disks.Disk[].InstanceId'
- Name: whetherDiskAttachedToInstance
Action: 'ACS::Choice'
Description:
en: Choose the next task based on the status of whether the disk is attached to ECS
zh-cn: 根据磁盘是否已挂载到ECS的状态选择下一个任务
Properties:
DefaultTask: waitUtilInstanceRunningOrStopped
Choices:
- When:
'Fn::Equals':
- - ''
- '{{ describeDisks.instanceIds }}'
NextTask: createSnapshot
- When:
'Fn::Equals':
- []
- '{{ describeDisks.instanceIds }}'
NextTask: ACS::END
- Name: waitUtilInstanceRunningOrStopped
Action: 'ACS::WaitFor'
Description:
en: Waits for ECS instance status enter to Running or Stopped status
zh-cn: 等待ECS实例的状态至运行中或已停止状态
Delay: 20
Retries: 30
DelayType: Constant
Properties:
Service: ECS
API: DescribeInstances
Parameters:
RegionId: '{{ regionId }}'
InstanceIds: '{{ describeDisks.instanceIds }}'
PropertySelector: 'Instances.Instance[].Status'
DesiredValues:
- Running
- Stopped
- Name: createSnapshot
Action: 'ACS::ExecuteAPI'
Description:
en: Creates a snapshot with the specified disk ID and snapshot name
zh-cn: 通过云盘ID创建一个快照
Properties:
Service: ECS
API: CreateSnapshot
Parameters:
RegionId: '{{ regionId }}'
DiskId: '{{ diskId }}'
SnapshotName: '{{ snapshotName }}'
Tags: '{{ tags }}'
RetentionDays:
'Fn::If':
- 'Fn::Equals':
- ''
- '{{ retentionDays }}'
- Null
- '{{ retentionDays }}'
Outputs:
snapshotId:
Type: String
ValueSelector: SnapshotId
- Name: untilSnapshotsReady
Action: 'ACS::WaitFor'
Description:
en: Waits for the snapshot to be accomplished
zh-cn: 等待快照创建完成
Retries: 57
Properties:
Service: ECS
API: DescribeSnapshots
Parameters:
RegionId: '{{ regionId }}'
SnapshotIds:
- '{{ createSnapshot.snapshotId }}'
DesiredValues:
- accomplished
StopRetryValues:
- failed
PropertySelector: 'Snapshots.Snapshot[].Status'
Outputs:
snapshotId:
Type: String
Value: '{{ createSnapshot.snapshotId }}'