Create a custom CloudOps Orchestration Service (OOS) template to bulk update tag values across hundreds of resources in a region.
Prerequisites
ECS instances are tagged. Create a tag, Add a tag to a resource.
Overview
This example changes the tag on hundreds of ECS instances from TagKey:OldTagValue to TagKey:NewTagValue.
-
Each execution handles up to 1,000 resources. Run the template multiple times for larger batches.
-
This template works with any taggable resource in a region. Adjust the API operations for your resource type. Services that work with Tag.Cloud services that OOS supports.
Step 1: Create a template
Create a custom OOS template to bulk update tag values:
-
Log in to the OOS console.
-
In the left-side navigation pane, choose .
-
In the top menu bar, select a region.
-
Click Create Template.
-
Click the JSON tab and enter the template content.
Example:
{ "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": {} } -
Click Create Template.
-
In the Template Basic Information dialog box, enter the template name, tag, resource group, and version description.
-
Click OK.
Step 2: Run the template
Run the template from Step 1 to update tag values in bulk.
-
On the Custom Template page, locate the template from Step 1 and click Create Execution in the Actions column.
-
Enter an Execution Description, select an Execution Mode, then click Next: Set Parameters.
-
Enter the parameters, then click Next: Confirm.
Parameters:
-
operateId: Custom identifier for this execution.
-
tagKey: Tag key to update. Example:
TagKey. -
tagValue: Current tag value. Example:
OldTagValue. -
newTagValue: Replacement tag value. Example:
NewTagValue.
-
-
Click Create.
After execution, you are redirected to the details page to view the results.
NoteIf execution fails, check the execution log for details.