A tag is a key-value pair that you attach to a resource. Tags let you categorize, search, and aggregate resources by shared characteristics. This topic walks you through creating predefined tags, adding them to resources, and applying tags to common scenarios.
Prerequisites
The resource type you want to tag must be supported. Cloud services that support tags.
Step 1: Create a predefined tag
A predefined tag applies across all regions, making it ideal for the planning phase. Plan your tags based on business requirements using Best practices for tag design, then create them and add them to resources. Create a tag.
-
Log on to the Tag console.
-
In the navigation pane on the left, choose . Then, click Create Tag.
-
In the Create Tag dialog box, set the tag key and tag value, then click Create.
For example, set Tag Key to
BusinessUnitand Tag Value toBeijing,Shanghai, andHangzhou.
Step 2: Add tags to resources
New resources
Add tags when you create a resource:
-
In the console of a cloud service, specify the tag when you create a resource. Refer to the documentation for the specific cloud service.
-
When you call an API operation to create a resource, specify the tag in the request parameters. Refer to the documentation for the specific cloud service.
The following example adds a tag when creating a VPC in the VPC console.
-
Log on to the VPC console.
-
Create a VPC and add a tag to it.
In the Resource Group and Tags section, set Tag Key to
BusinessUnitand Tag Value toBeijing.
Existing resources
Add tags to existing resources:
-
Console: Add tags to resources in the Tag console, the Resource Center console, or the console of the specific cloud service.
-
API: Call the TagResource operation or a tag-related API operation of a specific cloud service.
-
CloudOps Orchestration Service (OOS): Add tags to multiple resources at once. Use OOS to add tags to multiple ECS instances at once.
The following example uses the Tag console to add the predefined tag created in Step 1 to a resource.
-
Log on to the Tag console.
-
In the navigation pane on the left, choose .
-
In the list of predefined tags, find the tag you want to add and click Add to Resources in the Actions column.
NoteIf a tag key has more than three values, click View More to view all values.
-
In the Add to Resources dialog box, select the target resources.
For Method to Specify Resources, select one of the following:
-
Select from Resource List: Select resources from a list.
-
Enter Resource IDs: Select the service and region, and then enter the resource IDs. Separate multiple IDs with a comma.
-
-
Click Bind.
-
Use Tag inheritance to automatically propagate tag changes to associated resources when you manage the tags of a primary resource or associate it with other resources. For example, adding or removing a tag on an ECS instance automatically applies the change to its cloud disks, ENIs, and EIPs. Newly attached resources also inherit the instance tags.
-
Use tag policies to enforce compliance by specifying required tags on resources. Compliant tags improve cost allocation, access control, and automated O&M.
Use cases
After tagging resources, you can use tags with other cloud services to find resources, control access, and automate O&M.
|
Cloud service |
Use case |
Category |
References |
|
Tag |
Use the Tag console or API to find resources by specific tags. |
Find resources by tag |
|
|
CloudOps Orchestration Service (OOS) |
Tag resources by environment (production, test), OS (Windows Server, Linux), or client platform (iOS, Android), then create and run OOS templates to perform batch O&M tasks. |
Tag-based automated O&M |
|
|
Resource Access Management (RAM) |
Use tags with RAM to grant tag-based permissions to RAM users for cloud resources. |
Access control by tag |