All Products
Search
Document Center

Elastic Compute Service:Use tags to categorize and manage ECS resources

Last Updated:Sep 26, 2024

As the number of cloud resources increases, managing resources also becomes more difficult. For example, you may be unable to batch collect cost statistics about and perform O&M and monitoring on multiple cloud resources that serve the same purpose or belong to the same application category or organization to ensure that the resources are properly used and efficiently managed. To efficiently manage your resources, you can use tags to categorize the resources. Tags are an important grouping tool that help you in the horizontal management of personnel, finances, and materials and the fine-grained management of resources.

For more information about tags, see Tag overview.

Scenarios

As the number of Elastic Compute Service (ECS) instances that you create increases, you can use tags to manage, group, and categorize the instances to facilitate instance search and batch operations. Tags are suitable for scenarios that involve resource management, access control, automated O&M, and cost allocation. Sample scenarios:

  • Management of application publishing procedures

  • Resource tracking and tag-based group search and management

  • Tag-based and group-based automated O&M by using Alibaba Cloud services such as CloudOps Orchestration Service (OOS), Resource Orchestration Service (ROS), Auto Scaling, and Cloud Assistant

  • Tag-based cost management and cost allocation

  • Resource-based or role-based access control

The following examples describe how to use tags in two scenarios. For information about more tag scenarios, see Tag overview.

Scenario 1: Optimize the management of ECS resources or automate O&M on ECS resources

You can add different tags to different environments (such as production environments and test environments), operating systems (such as Windows Server and Linux), or client platforms (such as iOS and Android). For example, you can add the Test:Server-Windows tag to all ECS instances that are used in a test environment. Then, you can find the ECS instances based on the tags and perform operations on the instances.标签应用场景示例二

Examples of batch operations:

Scenario 2: Manage teams or projects

When you manage teams or projects, you can add tags such as CostCenter:aliyun to categorize groups, projects, or departments. This way, you can implement itemized billing and cross-authorization based on tags in the Expenses and Costs console.标签应用场景示例

For more information, see the following topics:

Usage notes

Each tag consists of a key and a value. Each tag key must be unique in a resource.

Important

Before you use tags, make sure that you understand the limits and quotas of tags. For more information, see the Limits section of the "Tag overview" topic.

ECS resources to which tags can be added

  • ECS instances

  • Disks

  • Reserved instances

  • Block storage devices

  • Snapshots

  • Snapshot-consistent groups

  • Automatic snapshot policies

  • Images

  • Image components

  • Image templates

  • Security groups

  • Elastic network interfaces (ENIs)

  • Dedicated hosts

  • SSH key pairs

  • Launch templates

  • Dedicated host groups

  • Elasticity assurances

  • Capacity reservations

  • Storage capacity units

  • Cloud Assistant commands

  • Execution results of Cloud Assistant commands or file sending tasks

  • Instances managed by Cloud Assistant

  • Activation codes for instances managed by Cloud Assistant

Create tags and add tags to resources

Before you create tags, make sure that you understand the background information, principles, and examples of tag design. For more information, see the Principles section of the "Best practices for tag design" topic. To create tags and add tags to resources, perform the steps in this section.

Important
  1. Log on to the ECS console.

  2. In the left-side navigation pane, click Tags.

  3. In the top navigation bar, select the region and resource group to which the resource belongs. 地域

  4. On the Custom Tags tab, click Create Custom Tag.

  5. In the Create Custom Tag dialog box, perform the following steps.

    When you create custom tags, you must add the tags to resources. If you want to create tags but do not want to add the tags to resources, create the tags as predefined tags. For more information, see Create a predefined tag.

    1. Create or select tags.

      tag

      Configure the parameters that are described in the following table.

      Parameter

      Required

      Description

      Tag key

      Yes

      Enter a new tag key or select an existing tag key.

      • The tag key can be up to 128 characters in length and cannot contain http:// or https://. The tag key cannot start with acs: or aliyun.

      • If you want to select an existing tag key, search for the tag key. Fuzzy search is supported.

      Tag value

      No

      Enter a new tag value.

      The tag value can be up to 128 characters in length and cannot contain http:// or https://.

      Note

      A tag key can correspond to multiple tag values. You can select an existing tag key and enter a new tag value to create a new tag.

    2. Click Next.

    3. Add the tags to resources.

      Configure the parameters described in the following table.

      Parameter

      Description

      Example

      Method to Specify Resources

      Valid values:

      • Select from Resource List: You can select one or more resources to which you want to add tags from the resource list.

      • Enter Resource IDs: You can enter resource IDs in the Resource ID field.

        Note
        • You can enter multiple resource IDs. Separate the IDs with commas (,) or enter the IDs on different lines.

        • You can add up to 20 tags to resources at a time.

      Enter Resource IDs

      Service

      Select a resource type. Example: Instance, Disk, or Snapshot.

      Elastic Compute Service:Instance

      Resource ID

      Enter the IDs of ECS instances in the Resource ID field.

      i-bp12d03u8usvakpo****

    4. Click OK.

    5. (Optional) View the associated resources of the tags.

      After the tags are created and added to resources, click the tag1 icon above the tag list on the Custom Tags tab, find the tags that you created, and then click View Resources in the Actions column that corresponds to each tag. On the page that appears, you can view the resources to which a tag is added.

      check resource

Remove or delete tags

If you no longer require a tag to manage or retrieve resources, you can remove the tag from the resources. The following section provides an example on how to remove the ECS:Documentation tag from the Elastic Compute Service:Instance resource type. The tag key is ECS and the tag value is Documentation.

Important
  • You can remove up to 20 tags at a time.

  • If you remove a tag from all resources, the tag is automatically deleted within 24 hours.

  1. On the Custom Tags tab, select Instance from the Resource Type drop-down list.

  2. In the tag list, find the ECS:Documentation tag that you want to remove. Go to the Resources tab by using one of the following methods.

    • Method 1: Click the ECS tag key, and then click View Resources in the Actions column that corresponds to the Documentation tag value.

    • Method 2: In the Actions column that corresponds to the ECS tag key, click View Resources.

  3. On the Resources tab, remove the tag from one or more resources.

    • To remove the tag from a single resource, find the resource and click Remove from Resources in the Actions column.

    • To remove the tag from multiple resources at a time, select the resources and click Remove Current Tag or Remove Tag from the Actions drop-down list in the lower part of the tab.

    remove resources

  4. In the Remove Current Tag message, click Remove.

    After the tag is removed from one or more resources, click the tag1.png icon on the Resources tab. The resources from which the tag is removed are no longer displayed on the tab.

Best practices for tags

You can use tags to manage resources in a fine-grained manner. In most cases, tags are used for the following purposes and to perform the following operations.

References

  • You can use resource groups to group your resources based on usage, permissions, and regions. Then, you can manage the resources in a hierarchical manner for various users and projects. For more information, see Resource Group overview or Resource groups.

  • For information about how to create and add tags to ECS resources, see TagResources.

  • For information about how to query the tags that are added to ECS resources, see ListTagResources.

  • For information about how to remove tags from ECS resources, see UntagResources.

  • For information about how to add an ECS resource or service to a resource group, see JoinResourceGroup.