-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathACS-ECS-CreateAndCopyImage.json
516 lines (516 loc) · 15.4 KB
/
ACS-ECS-CreateAndCopyImage.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
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
{
"FormatVersion": "OOS-2019-06-01",
"Description": {
"name-en": "ACS-ECS-CreateAndCopyImage",
"name-zh-cn": "创建ECS镜像并同步到其它地域",
"en": "Creates an ECS image and copies the new image to other regions, applicable to scenarios requiring creation and synchronization of ECS images across different regions, such as system updates and backups. During configuration, users need to provide the following required parameter information: Region ID (regionId), which specifies the region of the ECS instance for which the image will be created, ECS Instance ID (instanceId), which identifies the instance to create the image from, and Target Image Name (targetImageName), which names the new ECS image. Optionally, users may execute tasks on the instance via cloud assistant commands (commandContent). The created image will be synchronized to specified target regions (targetRegionIds), and users can also opt to share the image with other Alibaba Cloud accounts (accountIds). Upon execution, the template will return a list of the created and cloned image IDs, facilitating verification of the operations.",
"zh-cn": "创建一个新ECS镜像并且克隆新镜像到其他地域,适用于需要创建和同步ECS镜像到不同地域的场景,例如系统更新和备份。在配置过程中,用户需要提供以下必填参数信息,地域ID(regionId):用于指定需要创建镜像的ECS实例所在的地域,ECS实例ID(instanceId):用于指定要创建镜像的实例,目标镜像名称(targetImageName):用于为新的ECS镜像命名。此外,用户可以选择性地通过云助手命令(commandContent)在实例上运行脚本任务。创建后的镜像将被同步到指定的目标地域(targetRegionIds),用户也可以选择共享镜像到其他阿里云账户(accountIds)。模板在执行后会返回创建和克隆的镜像ID列表,方便用户验证操作结果。",
"categories": [
"image_manage"
]
},
"Parameters": {
"regionId": {
"Type": "String",
"Label": {
"en": "RegionId",
"zh-cn": "地域ID"
},
"AssociationProperty": "RegionId",
"Default": "{{ ACS::RegionId }}"
},
"instanceId": {
"Label": {
"en": "InstanceId",
"zh-cn": "ECS实例ID"
},
"Type": "String",
"AssociationProperty": "ALIYUN::ECS::Instance::InstanceId",
"AssociationPropertyMetadata": {
"RegionId": "regionId"
}
},
"targetImageName": {
"Label": {
"en": "TargetImageName",
"zh-cn": "新镜像的名称"
},
"Type": "String",
"Description": {
"en": "<p class=\"p\">Note:</p> <ul class=\"ul\"> <li class=\"li\">Length is 2~128 English or Chinese characters</li> <li class=\"li\"><font color='red'>must start with big or small letters or Chinese, not http:// and https://. </font></li> <li class=\"li\">Can contain numbers, colons (:), underscores (_), or dashes (-). </li> </ul>",
"zh-cn": "<p class=\"p\">注意:</p> <ul class=\"ul\"> <li class=\"li\">长度为2~128个英文或中文字符</li> <li class=\"li\"><font color='red'>必须以大小字母或中文开头,不能以http://和https://开头。</font></li> <li class=\"li\">可以包含数字、半角冒号(:)、下划线(_)或者短划线(-)。</li> </ul>"
},
"Default": "CreateImage_from_{{ACS::ExecutionId}}"
},
"commandType": {
"Label": {
"en": "CommandType",
"zh-cn": "云助手命令类型"
},
"Type": "String",
"AllowedValues": [
"RunShellScript",
"RunBatScript",
"RunPowerShellScript"
],
"Default": "RunShellScript"
},
"commandContent": {
"Description": {
"en": "<font color='red'><b>Command is not executed when value is empty</b></font>",
"zh-cn": "<font color='red'><b>命令为空时不会执行命令</b></font>"
},
"Label": {
"en": "CommandContent",
"zh-cn": "云助手命令"
},
"Type": "String",
"AssociationProperty": "Code",
"Default": ""
},
"targetRegionIds": {
"Label": {
"en": "TargetRegionIds",
"zh-cn": "目标地域ID"
},
"Type": "List",
"AllowedValues": [
"all-regions",
"cn-hangzhou",
"cn-shanghai",
"cn-nanjing",
"cn-qingdao",
"cn-beijing",
"cn-zhangjiakou",
"cn-huhehaote",
"cn-wulanchabu",
"cn-shenzhen",
"cn-heyuan",
"cn-guangzhou",
"cn-chengdu",
"cn-wuhan-lr",
"cn-fuzhou",
"cn-hongkong",
"ap-northeast-1",
"ap-northeast-2",
"ap-southeast-1",
"ap-southeast-2",
"ap-southeast-3",
"ap-southeast-5",
"ap-southeast-6",
"ap-southeast-7",
"ap-south-1",
"eu-central-1",
"eu-west-1",
"us-west-1",
"us-east-1",
"me-east-1",
"me-central-1"
],
"Default": []
},
"accountIds": {
"Label": {
"en": "AccountIds",
"zh-cn": "授权共享镜像的阿里云账号ID"
},
"Type": "List",
"Default": []
},
"scalingConfigurationIds": {
"Description": {
"en": "<font color='red'><b>Must correspond to the selected region</b></font>",
"zh-cn": "<font color='red'><b>必须要在所选的地域</b></font>"
},
"Label": {
"en": "ScalingConfigurationIds",
"zh-cn": "待修改的伸缩配置ID"
},
"Type": "List",
"Default": []
},
"launchTemplateNames": {
"Description": {
"en": "<font color='red'><b>Must correspond to the selected region</b></font>",
"zh-cn": "<font color='red'><b>必须要在所选的地域</b></font>"
},
"Label": {
"en": "LaunchTemplateNames",
"zh-cn": "待更新的实例启动模板名称列表"
},
"Type": "List",
"Default": []
},
"tags": {
"Label": {
"en": "Tags",
"zh-cn": "镜像标签"
},
"Type": "Json",
"AssociationProperty": "Tags",
"AssociationPropertyMetadata": {
"ShowSystem": false
},
"Default": []
},
"rateControl": {
"Label": {
"en": "RateControl",
"zh-cn": "任务执行的并发比率"
},
"Type": "Json",
"AssociationProperty": "RateControl",
"Default": {
"Mode": "Concurrency",
"MaxErrors": 0,
"Concurrency": 5
}
},
"OOSAssumeRole": {
"Label": {
"en": "OOSAssumeRole",
"zh-cn": "OOS扮演的RAM角色"
},
"Type": "String",
"Default": ""
}
},
"RamRole": "{{ OOSAssumeRole }}",
"Tasks": [
{
"Name": "whetherToRunCommand",
"Action": "ACS::Choice",
"Description": {
"en": "Choose next task",
"zh-cn": "选择下一个任务"
},
"Properties": {
"DefaultTask": "runCommand",
"Choices": [
{
"When": {
"Fn::Equals": [
"",
"{{ commandContent }}"
]
},
"NextTask": "createImage"
}
]
}
},
{
"Name": "runCommand",
"Action": "ACS::ECS::RunCommand",
"Description": {
"en": "Run cloud assistant command on ECS instance",
"zh-cn": "在实例中运行云助手命令"
},
"Properties": {
"regionId": "{{ regionId }}",
"instanceId": "{{ instanceId }}",
"commandContent": "{{ commandContent }}",
"commandType": "{{ commandType }}"
},
"Outputs": {
"commandOutput": {
"Type": "String",
"ValueSelector": "invocationOutput"
}
}
},
{
"Name": "createImage",
"Action": "ACS::ECS::CreateImage",
"Description": {
"en": "Create new image with the specified image name and instance ID",
"zh-cn": "通过指定实例ID和镜像名称创建新的镜像"
},
"Properties": {
"regionId": "{{ regionId }}",
"instanceId": "{{ instanceId }}",
"imageName": "{{ targetImageName }}-{{ ACS::CurrentUTCTime }}",
"tags": "{{tags}}"
},
"Outputs": {
"imageId": {
"ValueSelector": "imageId",
"Type": "String"
}
}
},
{
"Name": "queryAllAvailableRegions",
"Action": "ACS::ExecuteAPI",
"Description": {
"en": "View all available regions",
"zh-cn": "查询当前所有可用地域"
},
"Properties": {
"Service": "ECS",
"API": "DescribeRegions",
"Parameters": {
"RegionId": "{{ regionId }}"
}
},
"Outputs": {
"regionIds": {
"Type": "List",
"ValueSelector": "Regions.Region[]|.RegionId|select([scan(\"{{ACS::RegionId}}|test\")]|length<1)"
},
"allRegionsChosen": {
"Type": "String",
"ValueSelector": ".|{{targetRegionIds}}|sort|.[0]"
}
}
},
{
"Name": "whetherCloneToAllRegions",
"Action": "ACS::Choice",
"Description": {
"en": "Choose next task by targetRegionIds Chosen",
"zh-cn": "根据所选目的地域判断下一步执行"
},
"Properties": {
"DefaultTask": "copyImage",
"Choices": [
{
"When": {
"Fn::Equals": [
"all-regions",
"{{ queryAllAvailableRegions.allRegionsChosen }}"
]
},
"NextTask": "copyImageToAllRegions"
}
]
}
},
{
"Name": "copyImage",
"Action": "ACS::ECS::CopyImage",
"OnSuccess": "whetherToShareImage",
"Description": {
"en": "Copy image to regions chosen",
"zh-cn": "复制镜像到被指定的地域"
},
"Properties": {
"regionId": "{{ regionId }}",
"imageId": "{{ createImage.imageId }}",
"targetImageName": "{{ targetImageName }}-{{ ACS::CurrentUTCTime }}",
"targetRegionId": "{{ ACS::TaskLoopItem }}"
},
"Loop": {
"Items": "{{ targetRegionIds }}",
"RateControl": "{{ rateControl }}",
"Outputs": {
"imageIdsWithRegion": {
"AggregateType": "Fn::ListJoin",
"AggregateField": "imageIdWithRegion"
}
}
},
"Outputs": {
"imageIdWithRegion": {
"ValueSelector": ".|(.imageId),\"{{ ACS::TaskLoopItem }}\"",
"Type": "List"
}
}
},
{
"Name": "copyImageToAllRegions",
"Action": "ACS::ECS::CopyImage",
"Description": {
"en": "Copy image to all available regions",
"zh-cn": "复制镜像到所有可用地域"
},
"Properties": {
"regionId": "{{ regionId }}",
"imageId": "{{ createImage.imageId }}",
"targetImageName": "{{ targetImageName }}-{{ ACS::CurrentUTCTime }}",
"targetRegionId": "{{ ACS::TaskLoopItem }}"
},
"Loop": {
"Items": "{{ queryAllAvailableRegions.regionIds }}",
"RateControl": "{{ rateControl }}",
"Outputs": {
"imageIdsWithRegion": {
"AggregateType": "Fn::ListJoin",
"AggregateField": "imageIdWithRegion"
}
}
},
"Outputs": {
"imageIdWithRegion": {
"ValueSelector": ".|(.imageId),\"{{ ACS::TaskLoopItem }}\"",
"Type": "List"
}
}
},
{
"Name": "whetherToShareImage",
"Action": "ACS::Choice",
"Description": {
"en": "Choose next task by accountIds",
"zh-cn": "根据输入账户值判断下一步执行"
},
"Properties": {
"DefaultTask": "shareImage",
"Choices": [
{
"When": {
"Fn::Equals": [
[],
"{{ accountIds }}"
]
},
"NextTask": "modifyScalingConfiguration"
}
]
}
},
{
"Name": "shareImage",
"Action": "ACS::ExecuteAPI",
"Description": {
"en": "Shares a custom image to other Alibaba Cloud accounts",
"zh-cn": "共享自定义镜像到其他阿里云账号"
},
"Properties": {
"Service": "ECS",
"API": "ModifyImageSharePermission",
"Parameters": {
"RegionId": "{{ regionId }}",
"ImageId": "{{ createImage.imageId }}",
"AddAccount": "{{ accountIds }}"
}
}
},
{
"Name": "modifyScalingConfiguration",
"Action": "ACS::ExecuteAPI",
"OnError": "ACS::NEXT",
"Description": {
"en": "Modify scaling configuration",
"zh-cn": "修改伸缩配置"
},
"Properties": {
"Service": "ESS",
"API": "ModifyScalingConfiguration",
"Parameters": {
"RegionId": "{{ regionId }}",
"ScalingConfigurationId": "{{ ACS::TaskLoopItem }}",
"ImageId": "{{ createImage.imageId }}"
}
},
"Loop": {
"Items": "{{ scalingConfigurationIds }}"
}
},
{
"Name": "updateLaunchTemplate",
"Action": "ACS::ECS::UpdateLaunchTemplate",
"Description": {
"en": "Update instance launch template",
"zh-cn": "更新实例启动模板"
},
"Properties": {
"regionId": "{{ regionId }}",
"imageId": "{{ createImage.imageId }}",
"launchTemplateName": "{{ ACS::TaskLoopItem }}"
},
"Loop": {
"Items": "{{ launchTemplateNames }}"
}
}
],
"Outputs": {
"imageIds": {
"Type": "List",
"Value": "{{ createImage.imageId }}"
},
"imageIdAndRegion": {
"Type": "List",
"Value": {
"Fn::If": [
{
"Fn::Equals": [
"all-regions",
"{{ queryAllAvailableRegions.allRegionsChosen }}"
]
},
"{{ copyImageToAllRegions.imageIdsWithRegion }}",
"{{ copyImage.imageIdsWithRegion }}"
]
}
}
},
"Metadata": {
"ALIYUN::OOS::Interface": {
"ParameterGroups": [
{
"Parameters": [
"regionId",
"instanceId"
],
"Label": {
"default": {
"zh-cn": "选择实例",
"en": "Select Ecs Instances"
}
}
},
{
"Parameters": [
"targetImageName",
"tags"
],
"Label": {
"default": {
"zh-cn": "镜像设置",
"en": "Image Configure"
}
}
},
{
"Parameters": [
"commandType",
"commandContent"
],
"Label": {
"default": {
"zh-cn": "发送远程命令",
"en": "Run Command"
}
}
},
{
"Parameters": [
"targetRegionIds",
"accountIds"
],
"Label": {
"default": {
"zh-cn": "镜像分发",
"en": "Copy Image"
}
}
},
{
"Parameters": [
"scalingConfigurationIds",
"launchTemplateNames",
"rateControl",
"OOSAssumeRole"
],
"Label": {
"default": {
"zh-cn": "高级选项",
"en": "Control Options"
}
}
}
]
}
}
}