Buat templat kustom di CloudOps Orchestration Service (OOS) untuk memperbarui nilai tag secara massal pada ratusan resource dalam satu Wilayah.
Prasyarat
Instance ECS telah memiliki tag. Buat tag, Tambahkan tag ke resource.
Ikhtisar
Contoh ini memperbarui tag pada ratusan Instance ECS, mengubah pasangan kunci-nilai dari TagKey:OldTagValue menjadi TagKey:NewTagValue.
-
Setiap eksekusi menangani hingga 1.000 resource. Jalankan templat beberapa kali untuk batch yang lebih besar.
-
Templat ini berfungsi dengan semua resource yang dapat diberi tag dalam satu Wilayah. Sesuaikan Operasi API sesuai jenis resource Anda. Layanan yang mendukung Tag.Layanan cloud yang didukung OOS.
Langkah 1: Buat templat
Buat templat OOS kustom untuk memperbarui nilai tag secara massal:
-
Masuk ke Konsol OOS.
-
Di panel navigasi sebelah kiri, pilih .
-
Di pojok kiri atas bilah menu, pilih Wilayah.
-
Klik Create Template.
-
Klik tab JSON, lalu masukkan konten templat.
Contoh:
{ "Description": "Bulk update the tag values of resources.", "FormatVersion": "OOS-2019-06-01", "Parameters": { "operateId": { "Description": "Enter a custom operation ID.", "Type": "String", "MinLength": 1, "MaxLength": 64 }, "tagKey": { "Description": "The key of the tag to update.", "Type": "String", "MinLength": 1, "MaxLength": 64 }, "tagValue": { "Description": "The current value of the tag.", "Type": "String", "MinLength": 1, "MaxLength": 64 }, "newTagValue": { "Description": "The new value for the tag.", "Type": "String", "MinLength": 1, "MaxLength": 64 } }, "Tasks": [ { "Name": "DescribeInstances_ECS", "Action": "ACS::ExecuteAPI", "Description": { "en": "Filter ECS instances by tags" }, "Properties": { "Service": "ECS", "API": "DescribeInstances", "AutoPaging": true, "Parameters": { "Tags": [ { "Key": "{{ tagKey }}", "Value": "{{ tagValue }}" } ] } }, "Outputs": { "Instances": { "Type": "List", "ValueSelector": "Instances.Instance[].InstanceId" } } }, { "Name": "TagResources_ECS_Instances", "Action": "ACS::ExecuteAPI", "Description": { "en": "Update tags for ECS instances" }, "Properties": { "Service": "ECS", "API": "TagResources", "Parameters": { "Tags": [ { "Key": "{{ tagKey }}", "Value": "{{ newTagValue }}" } ], "ResourceType": "Instance", "ResourceId": [ "{{ACS::TaskLoopItem}}" ] } }, "Loop": { "MaxErrors": "100%", "Concurrency": 20, "Items": "{{DescribeInstances_ECS.Instances}}" } } ], "Outputs": {} } -
Klik Create Template.
-
Pada kotak dialog Template Basic Information, masukkan nama templat, tag, kelompok sumber daya, dan deskripsi versi.
-
Klik OK.
Langkah 2: Jalankan templat
Jalankan templat dari Langkah 1 untuk memperbarui nilai tag secara massal.
-
Pada halaman Custom Template, temukan templat dari Langkah 1, lalu klik Create Execution di kolom Actions.
-
Masukkan Execution Description, pilih Execution Mode, lalu klik Next: Set Parameters.
-
Masukkan parameter, lalu klik Next: Confirm.
Parameter:
-
operateId: ID kustom untuk mengidentifikasi eksekusi ini.
-
tagKey: Kunci tag yang akan diperbarui. Contoh:
TagKey. -
tagValue: Nilai tag saat ini. Contoh:
OldTagValue. -
newTagValue: Nilai tag baru. Contoh:
NewTagValue.
-
-
Klik Create.
Setelah eksekusi, Anda akan diarahkan ke halaman detail untuk melihat hasilnya.
CatatanJika eksekusi gagal, periksa log eksekusi untuk detailnya.