-
Notifications
You must be signed in to change notification settings - Fork 17
/
ACS::ECS::DetachNetworkInterfaceAndDeleteEip.yml
191 lines (191 loc) · 5.63 KB
/
ACS::ECS::DetachNetworkInterfaceAndDeleteEip.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
FormatVersion: OOS-2019-06-01
Description:
name-en: ACS::ECS::DetachNetworkInterfaceAndDeleteEip
name-zh-cn: 卸载弹性网卡并释放EIP
en: Detach the network interface from the special instance and release EIP
zh-cn: 从实例上卸载弹性网卡并释放EIP
Parameters:
regionId:
Description:
en: The ID of region
zh-cn: 地域ID
Type: String
Default: '{{ ACS::RegionId }}'
instanceId:
Description:
en: The ID of ECS instance
zh-cn: ECS实例ID
Type: String
Tasks:
- Name: waitInstanceReady
Action: 'ACS::WaitFor'
Delay: 15
Retries: 7
DelayType: Constant
Description:
en: Waits for ECS instance tnter to Running or Stopped status
zh-cn: 等待ECS实例状态至运行中或已停止状态
Properties:
Service: ECS
API: DescribeInstances
Parameters:
InstanceIds:
- '{{ instanceId }}'
DesiredValues:
- Running
- Stopped
PropertySelector: 'Instances.Instance[].Status'
- Name: describeNetworkInterfaces
Action: 'ACS::ExecuteAPI'
Description:
en: Queries the network interfaces ID
zh-cn: 获取弹性网卡ID
Properties:
Service: ECS
API: DescribeNetworkInterfaces
Parameters:
InstanceId: '{{ instanceId }}'
Type: 'Secondary'
Outputs:
networkInterfaceId:
Type: List
ValueSelector: 'NetworkInterfaceSets.NetworkInterfaceSet[].NetworkInterfaceId'
- Name: describeEipAddresses
Action: 'ACS::ExecuteAPI'
Description:
en: Queries the allocationId of EIP
zh-cn: 获取EIP的实例ID
Properties:
Service: ECS
API: DescribeEipAddresses
Parameters:
AssociatedInstanceId: '{{ ACS::TaskLoopItem }}'
AssociatedInstanceType: 'NetworkInterface'
Outputs:
allocationId:
Type: Json
ValueSelector: 'EipAddresses.EipAddress[] | {"allocationId":.AllocationId, "networkInterfaceId":.InstanceId}'
Loop:
Items: '{{ describeNetworkInterfaces.networkInterfaceId }}'
Outputs:
allocationIdInfo:
AggregateType: 'Fn::ListJoin'
AggregateField: allocationId
- Name: unassociateEipAddress
Action: 'ACS::ExecuteAPI'
Description:
en: Unasscocaties the eip from network interface
zh-cn: 将弹性公网IP(EIP)从绑定的云产品上解绑
OnError: waitEipAddressReady
Properties:
Service: ECS
API: UnassociateEipAddress
Parameters:
RegionId: '{{ regionId }}'
AllocationId:
'Fn::Select':
- 'allocationId'
- '{{ ACS::TaskLoopItem }}'
InstanceId:
'Fn::Select':
- 'networkInterfaceId'
- '{{ ACS::TaskLoopItem }}'
InstanceType: 'NetworkInterface'
Loop:
Items: '{{ describeEipAddresses.allocationIdInfo }}'
- Name: waitEipAddressReady
Action: 'ACS::WaitFor'
Description:
en: Waits for the EIP enter to Available status
zh-cn: 等待EIP进入可用状态
Delay: 15
Retries: 7
DelayType: Constant
OnError: releaseEipAddress
Properties:
Service: ECS
API: DescribeEipAddresses
Parameters:
AllocationId:
'Fn::Select':
- 'allocationId'
- '{{ ACS::TaskLoopItem }}'
DesiredValues:
- Available
PropertySelector: 'EipAddresses.EipAddress[].Status'
Loop:
Items: '{{ describeEipAddresses.allocationIdInfo }}'
- Action: 'ACS::ExecuteAPI'
Name: releaseEipAddress
Description:
en: Releases the EIP
zh-cn: 释放EIP
OnError: detachNetworkInterface
Properties:
Service: ECS
API: ReleaseEipAddress
Parameters:
RegionId: '{{ regionId }}'
AllocationId:
'Fn::Select':
- 'allocationId'
- '{{ ACS::TaskLoopItem }}'
Loop:
Items: '{{ describeEipAddresses.allocationIdInfo }}'
- Action: 'ACS::ExecuteAPI'
Name: detachNetworkInterface
Description:
en: Detaches the network interface
zh-cn: 从一台ECS实例上分离一个弹性网卡
OnError: waitNetworkInterfaceAvailable
Properties:
Service: ECS
API: DetachNetworkInterface
Parameters:
RegionId: '{{ regionId }}'
InstanceId: '{{ instanceId }}'
NetworkInterfaceId:
'Fn::Select':
- 'networkInterfaceId'
- '{{ ACS::TaskLoopItem }}'
Loop:
Items: '{{ describeEipAddresses.allocationIdInfo }}'
- Name: waitNetworkInterfaceAvailable
Action: 'ACS::WaitFor'
Description:
en: Waits for the network interface util Available
zh-cn: 等待弹性网卡至可用状态
Delay: 15
Retries: 7
DelayType: Constant
OnError: deleteNetworkInterface
Properties:
Service: ECS
API: DescribeNetworkInterfaces
Parameters:
RegionId: '{{ regionId }}'
NetworkInterfaceId:
- 'Fn::Select':
- 'networkInterfaceId'
- '{{ ACS::TaskLoopItem }}'
DesiredValues:
- Available
PropertySelector: 'NetworkInterfaceSets.NetworkInterfaceSet[].Status'
Loop:
Items: '{{ describeEipAddresses.allocationIdInfo }}'
- Action: 'ACS::ExecuteAPI'
Name: deleteNetworkInterface
Description:
en: Deletes the network interface
zh-cn: 删除一个弹性网卡
Properties:
Service: ECS
API: DeleteNetworkInterface
Parameters:
RegionId: '{{ regionId }}'
NetworkInterfaceId:
'Fn::Select':
- 'networkInterfaceId'
- '{{ ACS::TaskLoopItem }}'
Loop:
Items: '{{ describeEipAddresses.allocationIdInfo }}'