All Products
Search
Document Center

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

Last Updated:May 27, 2024

As the number of cloud resources increases, the difficulty in managing the resources also increases. 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 helps 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. Example 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, 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, add the Test:Server-Windows tag to all ECS instances that are used in a test environment. Then, you can find these 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, you must 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 or add tags

Before you create tags, learn about 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 or add tags, 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. Up to 10 custom tags can be created at the same time, and each custom tag key must be unique. 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.

      Note

      If you want to create a tag, enter a new tag key. If you want to add an existing tag, select its 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.

      • You can search for an existing tag key that you want to add. Fuzzy search is supported. Up to 10 tag keys can be added at a time.

      Tag value

      No

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

      Note

      If you want to add an existing tag, select its tag value.

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

      • You can search for an existing tag value that you want to add. Fuzzy search is supported. Up to 10 tag values can be added at a time.

    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:

      • Resources: 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.

      Enter Resource IDs

      Resource Type

      Select a resource type of a service. 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, click the tag1 icon above the tag list on the Custom Tags tab, find the tags that you added, 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 was added.

      check resource

Remove or delete tags

If you no longer need 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 a tag named ECS:Documentation from one or more ECS instances.

Important
  • Up to 20 tags can be removed at a time.

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

  1. Log on to the ECS console.

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

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

  4. 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.

    Note

    In the ECS:Documentation tag, the tag key is ECS and the tag value is Documentation.

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

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

  5. 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 in the lower part of the tab.

    remove resources

  6. 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. Tags are commonly 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.