Attach key-value pair tags to ECS resources for grouping, batch operations, cost splitting, and access control.
See What are tags? for tag concepts and details.
Use cases
Tags simplify searching and batch operations on ECS resources. Common use cases include:
-
Manage application release processes
-
Retrieve and manage resources in groups
-
Automate group-based O&M with CloudOps Orchestration Service, Resource Orchestration Service, Auto Scaling (ESS), and Cloud Assistant
-
Manage costs and split bills
-
Design access control for resources or roles
The following two scenarios are described in detail. See What are tags? for more use cases.
Optimize ECS resource management and automate O&M
Attach tags to differentiate environments (production, staging), operating systems (Windows, Linux), or platforms (iOS, Android). For example, attach Test:Server-Windows to all staging instances to quickly filter them during maintenance.
Examples of batch operations:
-
Replace images to deploy applications.
-
Upgrade patches.
-
Add security group rules to control network access.
See Use tags to retrieve ECS instances and add them to a security group with the same tags.
-
Start, stop, or restart ECS instances in batches with CloudOps Orchestration Service.
See Use OOS to start ECS instances with a specific tag in batches.
-
Run O&M scripts on multiple ECS instances with Cloud Assistant.
See Use tags to control the execution of Cloud Assistant commands.
Manage teams and projects
Add tags based on group, project, or department dimensions, such as CostCenter:aliyun, for grouping, bill splitting in User Center, or cross-account authorization.
Related topics:
Usage notes
Tags are key-value pairs. Each tag key attached to a resource must be unique.
Review tag limits and quotas in What are tags? before using tags.
Create and attach tags
Before creating tags, see Tag design principles for background and examples. To create and attach tags:
A maximum of 20 tags can be attached to a single resource. Detach existing tags before attaching new ones if you reach this limit.
Go to ECS console - Tags.
In the upper-left corner of the page, select a region and resource group.
-
On the Custom Tags tab, click Create Custom Tag.
-
On the Create Custom Tag page, complete the following steps.
You must attach a resource when creating a custom tag. To create a tag without attaching it, use predefined tags. See Create a tag.
-
Create a new tag.

Parameters:
Parameter
Required
Description
Tag Key
Yes
Enter a new tag key or select an existing one.
-
A new key can be up to 128 characters and cannot start with aliyun or acs:. It cannot contain http:// or https://.
-
Fuzzy search is supported when selecting an existing key.
Value
No
Enter a new tag value.
A new value can be up to 128 characters and cannot contain http:// or https://.
NoteThe same tag key can have different values. You can create a new tag by selecting an existing key and entering a new value.
-
-
Click Next.
-
Configure the resource attachment parameters.
Parameters:
Parameter
Description
Example
Resource Selection Method
Select resources in one of the following ways:
-
Select from Resource List: Select one or more resources from the list.
-
Enter Multiple Resource IDs: Enter resource IDs in the Search by resource ID text box.
Note-
Enter multiple resource IDs on separate lines or separate them with commas (,).
-
You can attach a maximum of 20 tags per request.
-
Enter Multiple Resource IDs
Service
The resource type. ECS resources include instances, disks, and snapshots.
Elastic Compute Service:Instance
Enter Resource ID
The ECS instance ID.
i-bp12d03u8usvakpo****
-
-
Click OK.
-
(Optional) View attached resources.
After creating and binding a tag, click the
icon above the Custom Tags list, find the tag, and click View Resources in the Actions column.
-
Detach or delete tags
If a tag is no longer needed, detach it from the resource. This example detaches the tag ECS:Documentation (key: ECS, value: Documentation) from an Elastic Compute Service: Instance resource.
-
You can detach a maximum of 20 tags at a time.
-
After a tag is detached from all resources, it is automatically deleted within 24 hours.
-
On the Custom Tags tab, set the resource type to Instance.
-
In the tag list, locate the ECS:Documentation tag to detach. Go to the Resources page in either of the following ways.
-
Method 1: Click the ECS tag key. Find the Documentation tag value and click View Resources in the Actions column.
-
Method 2: For the ECS tag key, click View Resources in the Actions column.
-
-
On the Resources tab, detach the tag from one or more resources.
-
To detach from a single resource: find the resource and click Detach Resource in the Actions column.
-
To detach from multiple resources: select the resources and click Detach Current Tag or Unbind Tags.

-
-
In the Detach Resource dialog box, click OK.
After detaching the tag, click the
icon on the Resources page to confirm the tag is no longer associated with the resource.
Best practices for tags
Common tag use cases and corresponding operations:
-
Find or export resources
-
Use the tag editor to edit resource tags and export resource information.
-
Use tags to find resources with exact and fuzzy search.
-
-
Use tags to control resource access
-
Use tags to group and grant permissions on ECS instances so that RAM users can view and manage only authorized resources.
-
Use tags to restrict RAM users from managing specified ECS instances by specifying authorized tags in a custom RAM policy.
-
-
Use tags for automated O&M
-
Use OOS to start ECS instances with a specific tag in batches.
-
Allow disks, ENIs, EIPs, snapshots, and custom images to inherit the tags of their parent ECS instances in batches with an OOS task template.
-
Use tags to retrieve ECS instances and add them to a security group with the same tags with an OOS task template.
-
Use CloudMonitor smart tag sync to automatically add ECS instances to a CloudMonitor application group for group-based monitoring.
-
Use tags to control the execution of Cloud Assistant commands or upload files on tagged instances in batches.
-
References
-
You can also use resource groups for hierarchical management based on purpose, permissions, and ownership. See What is a resource group? or Resource groups.
-
Call TagResources to create and attach tags.
-
Call ListTagResources to query tags attached to a resource.
-
Call UntagResources to detach tags from specified resources.
-
Call JoinResourceGroup to add an ECS resource to a resource group.