-
Notifications
You must be signed in to change notification settings - Fork 17
/
ACS-ECS-ApproveROSCreateInstances.json
325 lines (325 loc) · 12.5 KB
/
ACS-ECS-ApproveROSCreateInstances.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
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
{
"FormatVersion": "OOS-2019-06-01",
"Description": {
"en": "Create ECS instances by ROS with approval",
"zh-cn": "审批通过ROS创建ECS",
"name-en": "ACS-ECS-ApproveROSCreateInstances",
"name-zh-cn": "审批通过ROS创建ECS",
"categories": [
"cost_manage"
]
},
"Parameters": {
"regionId": {
"Type": "String",
"Label": {
"en": "RegionId",
"zh-cn": "地域ID"
},
"AssociationProperty": "RegionId",
"Default": "{{ ACS::RegionId }}"
},
"imageId": {
"Label": {
"en": "ImageId",
"zh-cn": "将创建实例的镜像ID"
},
"Type": "String",
"AssociationProperty": "ALIYUN::ECS::Image::ImageId",
"AssociationPropertyMetadata": {
"RegionId": "regionId"
}
},
"instanceType": {
"Label": {
"en": "InstanceType",
"zh-cn": "将创建实例的规格"
},
"Type": "String",
"AssociationProperty": "ALIYUN::ECS::Instance::InstanceType"
},
"zoneId": {
"Label": {
"en": "ZoneId",
"zh-cn": "将创建交换机的目标可用区ID"
},
"AssociationProperty": "ALIYUN::ECS::Instance::ZoneId",
"Type": "String",
"AssociationPropertyMetadata": {
"RegionId": "regionId"
}
},
"webHookUrl": {
"Label": {
"en": "WebHookUrl",
"zh-cn": "钉钉群助手的webhook地址"
},
"Description": {
"en": "e.g.https://oapi.dingtalk.com/robot/send?access_token=1234zxcvaksdq31414,acquiring DingTalk webhook please refer to second appendix in https://help.aliyun.com/document_detail/144679.html.",
"zh-cn": "形如https://oapi.dingtalk.com/robot/send?access_token=1234zxcvaksdq31414,具体钉钉WebHook获取请参考https://help.aliyun.com/document_detail/144679.html#h2--2-webhook-5。"
},
"Type": "String"
},
"atMobiles": {
"Label": {
"en": "AtMobiles",
"zh-cn": "审批通知中被@的群成员的钉钉手机号"
},
"Type": "List"
},
"atAll": {
"Label": {
"en": "AtAll",
"zh-cn": "当群助手向钉钉群中发送审批通知时是否@所有人"
},
"Type": "String",
"Default": "false"
},
"approvers": {
"Label": {
"en": "Approvers",
"zh-cn": "可以审批任务的用户"
},
"Description": {
"en": "the name to fill is the front part of @ in the RAM user name,if RAM user is user001@companyAlias.onaliyun.com, then fill user001 in list.",
"zh-cn": "用户名是RAM子用户名称中@前面的部分,比如RAM子用户为user001@companyAlias.onaliyun.com,那么列表中填写user001即可"
},
"Type": "List",
"AssociationProperty": "ALIYUN::RAM::User"
},
"minRequiredApprovals": {
"Label": {
"en": "MinRequiredApprovals",
"zh-cn": "最低需要通过审批的数量"
},
"Type": "Number",
"Default": 1
},
"instancesCount": {
"Label": {
"en": "InstancesCount",
"zh-cn": "将创建实例的数量"
},
"Type": "Number"
},
"OOSAssumeRole": {
"Label": {
"en": "OOSAssumeRole",
"zh-cn": "OOS扮演的RAM角色"
},
"Type": "String",
"Default": ""
}
},
"RamRole": "{{ OOSAssumeRole }}",
"Tasks": [
{
"Name": "approveCreateInstances",
"Action": "ACS::Approve",
"Description": {
"en": "Approve task creating ECS instances",
"zh-cn": "审批后批量创建ECS实例"
},
"Properties": {
"Approvers": "{{approvers}}",
"MinRequiredApprovals": "{{minRequiredApprovals}}",
"NotifyType": "WebHook",
"WebHook": {
"URI": "{{webhookUrl}}",
"Headers": {
"Content-Type": "application/json"
},
"Content": {
"msgtype": "text",
"text": {
"content": "Notify: Please approve the task execution to create ECS instance sent by {{ACS::RegionId}} oos {{ACS::ExecutionId}}."
},
"at": {
"atMobiles": "{{atMobiles}}",
"isAtAll": "{{atAll}}"
}
}
}
}
},
{
"Name": "createStack",
"Action": "ACS::ExecuteAPI",
"Description": {
"en": "Create a resource stack",
"zh-cn": "创建资源栈"
},
"Properties": {
"Service": "ROS",
"API": "CreateStack",
"Parameters": {
"RegionId": "{{ regionId }}",
"StackName": "OOS-{{ACS::ExecutionId}}",
"TimeoutInMinutes": 10,
"DisableRollback": false,
"Parameters": [
{
"ParameterKey": "instanceType",
"ParameterValue": "{{ instanceType }}"
},
{
"ParameterKey": "zoneId",
"ParameterValue": "{{ zoneId }}"
},
{
"ParameterKey": "regionId",
"ParameterValue": "{{ regionId }}"
},
{
"ParameterKey": "imageId",
"ParameterValue": "{{imageId}}"
},
{
"ParameterKey": "executionId",
"ParameterValue": "{{ ACS::ExecutionId }}"
},
{
"ParameterKey": "instancesCount",
"ParameterValue": "{{ instancesCount }}"
}
],
"TemplateBody": "{\n \"Description\": \"Create VPC ECS instance\",\n \"Parameters\": {\n \"imageId\": {\n \"Type\": \"String\"\n },\n \"instanceType\": {\n \"Type\": \"String\"\n },\n \"executionId\": {\n \"Type\": \"String\"\n },\n \"instancesCount\": {\n \"Type\": \"String\"\n },\n \"zoneId\": {\n \"Type\": \"String\"\n },\n \"regionId\": {\n \"Type\": \"String\"\n },\n \"resourcePrefix\": {\n \"Type\": \"String\",\n \"Default\": \"oos-generated\"\n }\n },\n \"ROSTemplateFormatVersion\": \"2015-09-01\",\n \"Outputs\": {\n \"ecs_instance_id\": {\n \"Value\": {\n \"Fn::GetAtt\": [\n \"ecs\",\n \"InstanceIds\"\n ]\n }\n }\n },\n \"Resources\": {\n \"vswitch\": {\n \"Type\": \"ALIYUN::ECS::VSwitch\",\n \"Properties\": {\n \"VpcId\": {\n \"Ref\": \"vpc\"\n },\n \"Description\": {\n \"Fn::Join\": [\n \" \",\n [\n \"OOS execution id is\",\n {\n \"Ref\": \"executionId\"\n }\n ]\n ]\n },\n \"ZoneId\": {\n \"Ref\": \"zoneId\"\n },\n \"CidrBlock\": \"192.168.0.0/16\"\n }\n },\n \"sg\": {\n \"Type\": \"ALIYUN::ECS::SecurityGroup\",\n \"Properties\": {\n \"Tags\": [\n {\n \"Key\": \"oos-generated\",\n \"Value\": {\n \"Ref\": \"executionId\"\n }\n },\n {\n \"Key\": \"region\",\n \"Value\": {\n \"Ref\": \"regionId\"\n }\n }\n ],\n \"VpcId\": {\n \"Ref\": \"vpc\"\n },\n \"SecurityGroupName\": {\n \"Fn::Join\": [\n \"-\",\n [\n {\n \"Ref\": \"resourcePrefix\"\n },\n \"sg\"\n ]\n ]\n },\n \"SecurityGroupEgress\": [\n {\n \"PortRange\": \"-1/-1\",\n \"Priority\": 1,\n \"IpProtocol\": \"all\",\n \"DestCidrIp\": \"0.0.0.0/0\",\n \"NicType\": \"intranet\"\n }\n ]\n }\n },\n \"vpc\": {\n \"Type\": \"ALIYUN::ECS::VPC\",\n \"Properties\": {\n \"CidrBlock\": \"192.168.0.0/16\",\n \"Description\": {\n \"Fn::Join\": [\n \" \",\n [\n \"OOS execution id is\",\n {\n \"Ref\": \"executionId\"\n }\n ]\n ]\n },\n \"VpcName\": {\n \"Fn::Join\": [\n \"-\",\n [\n {\n \"Ref\": \"resourcePrefix\"\n },\n \"vpc\"\n ]\n ]\n }\n }\n },\n \"ecs\": {\n \"Type\": \"ALIYUN::ECS::InstanceGroup\",\n \"Properties\": {\n \"ImageId\": {\n \"Ref\": \"imageId\"\n },\n \"SecurityGroupId\": {\n \"Ref\": \"sg\"\n },\n \"VpcId\": {\n \"Ref\": \"vpc\"\n },\n \"VSwitchId\": {\n \"Ref\": \"vswitch\"\n },\n \"InstanceType\": {\n \"Ref\": \"instanceType\"\n },\n \"MinAmount\": {\n \"Ref\": \"instancesCount\"\n },\n \"MaxAmount\": {\n \"Ref\": \"instancesCount\"\n },\n \"Tags\": [\n {\n \"Key\": \"oos-generated\",\n \"Value\": {\n \"Ref\": \"executionId\"\n }\n },\n {\n \"Key\": \"region\",\n \"Value\": {\n \"Ref\": \"regionId\"\n }\n }\n ]\n }\n }\n },\n \"Metadata\": {\n \"ALIYUN::ROS::Interface\": {\n \"TemplateTags\": [\n \"acs:integrate:oos:ecs_approve_ros_create_instances\"\n ]\n }\n }\n}\n"
}
},
"Outputs": {
"StackId": {
"Type": "String",
"ValueSelector": "StackId"
}
}
},
{
"Name": "untilStackReady",
"OnSuccess": "ACS::END",
"OnError": "queryStackStatusReason",
"Action": "ACS::WaitFor",
"Description": {
"en": "Wait for the stack status CREATE_COMPLETE",
"zh-cn": "等待资源栈至创建成功状态"
},
"Properties": {
"Service": "ROS",
"API": "GetStack",
"Parameters": {
"RegionId": "{{ regionId }}",
"StackId": "{{createStack.StackId}}"
},
"DesiredValues": [
"CREATE_COMPLETE"
],
"StopRetryValues": [
"CREATE_FAILED",
"CHECK_FAILED",
"ROLLBACK_FAILED",
"ROLLBACK_COMPLETE",
"CREATE_ROLLBACK_COMPLETE"
],
"PropertySelector": "Status"
},
"Outputs": {
"instanceIds": {
"Type": "String",
"ValueSelector": "Outputs[0].OutputValue"
}
}
},
{
"Name": "queryStackStatusReason",
"Action": "ACS::ExecuteAPI",
"OnError": "deleteStack",
"OnSuccess": "deleteStack",
"Description": {
"en": "Query the reson of failed created stack",
"zh-cn": "查询资源栈未创建成功的原因"
},
"Properties": {
"Service": "ROS",
"API": "GetStack",
"Parameters": {
"RegionId": "{{ regionId }}",
"StackId": "{{createStack.StackId}}"
}
},
"Outputs": {
"statusReason": {
"Type": "String",
"ValueSelector": "StatusReason"
}
}
},
{
"Name": "deleteStack",
"Action": "ACS::ExecuteApi",
"Description": {
"en": "Delete the stack",
"zh-cn": "删除资源栈"
},
"Properties": {
"Service": "ROS",
"API": "DeleteStack",
"Parameters": {
"RegionId": "{{ regionId }}",
"StackId": "{{createStack.StackId}}"
}
}
}
],
"Outputs": {
"instanceIds": {
"Type": "List",
"Value": "{{ untilStackReady.instanceIds }}"
}
},
"Metadata": {
"ALIYUN::OOS::Interface": {
"ParameterGroups": [
{
"Parameters": [
"webHookUrl",
"atMobiles",
"atAll",
"approvers",
"minRequiredApprovals"
],
"Label": {
"default": {
"zh-cn": "配置审批",
"en": "Configure Approval"
}
}
},
{
"Parameters": [
"regionId",
"zoneId",
"imageId",
"instanceType",
"instancesCount"
],
"Label": {
"default": {
"zh-cn": "配置实例",
"en": "Configure ECS Instance"
}
}
},
{
"Parameters": [
"OOSAssumeRole"
],
"Label": {
"default": {
"zh-cn": "高级选项",
"en": "Control Options"
}
}
}
]
}
}
}