All Products
Search
Document Center

Elastic Compute Service:DescribeTags

Last Updated:Jun 18, 2026

Queries tags available to you. You can perform a conditional query for tags based on resource type, resource ID, tag key, or tag value. The filter conditions are evaluated by using a logical AND (&&) operator, and only tags that meet all filter conditions are returned.

Note

This API has been deprecated. We recommend migrating to Tag(2018-08-28) - CountResourcesByTags for enhanced functionality and continued support. While the deprecated API remains temporarily accessible, no further updates or bug fixes will be provided.

Operation description

If you specify a tag key (Tag.N.Key) without specifying a tag value (Tag.N.Value), all tag key-value pairs associated with the tag key are returned. If you specify a tag key-value pair, only the tag that is an exact match of the key-value pair is returned.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

ecs:DescribeTags

get

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

PageSize

integer

No

The number of entries per page for a paged query.

Maximum value: 100.

Default value: 50.

50

PageNumber

integer

No

The page number of the tag list.

Minimum value: 1.

Default value: 1.

1

ResourceType

string

No

The resource type. Valid values:

  • instance: ECS instance.

  • disk: cloud disk.

  • snapshot: snapshot.

  • image: image.

  • securitygroup: security group.

  • volume: storage volume.

  • eni: network interface controller (NIC).

  • ddh: dedicated host.

  • keypair: SSH key pair.

  • launchtemplate: launch template.

  • reservedinstance: reserved instance.

  • snapshotpolicy: automatic snapshot policy.

All valid values are in lowercase.

snapshot

ResourceId

string

No

The ID of the resource to which the tag is attached. For example, if the resource type (ResourceType) is instance, the resource ID is the instance ID.

s-946ntx4wr****

RegionId

string

Yes

The region ID. You can call DescribeRegions to query the most recent region list.

cn-hangzhou

Category

string

No

Note

This parameter is about to be deprecated. To ensure compatibility, use other parameters.

null

Tag

array<object>

No

The list of tags.

object

No

The list of tags.

key

string

No

The tag key of the resource.

Note

To ensure compatibility, use the Tag.N.Key parameter.

testkey

Key

string

No

The tag key of the resource. Valid values of N: 1 to 20. The tag key cannot be an empty string. The tag key can be up to 64 characters in length and cannot start with aliyun or acs:. The tag key cannot contain http:// or https://.

TestKey

Value

string

No

The tag value of the resource. Valid values of N: 1 to 20. The tag value can be an empty string. The tag value can be up to 128 characters in length and cannot start with aliyun or acs:. The tag value cannot contain http:// or https://.

TestValue

value

string

No

The tag value of the resource.

Note

To ensure compatibility, use the Tag.N.Value parameter.

testvalue

Response elements

Element

Type

Description

Example

object

RequestId

string

The request ID.

B04B8CF3-4489-432D-83BA-6F128E4F2295

PageSize

integer

The number of entries per page settings for the paged query. This is the paging size.

50

PageNumber

integer

The page number of the tag list.

1

TotalCount

integer

The total number of tags.

1

Tags

object

Tag

array<object>

The tags that meet all filter conditions.

array<object>

The tags that meet all filter conditions.

TagValue

string

The tag value.

TestValue

TagKey

string

The tag key.

TestKey

ResourceTypeCount

object

The number of resources to which the tag is added.

Instance

integer

The number of instances to which the tag is added.

45

Image

integer

The number of images to which the tag is added.

6

Ddh

integer

The number of dedicated hosts to which the tag is added.

1

SnapshotPolicy

integer

The number of automatic snapshot policies to which the tag is added.

4

Securitygroup

integer

The number of security groups to which the tag is added.

4

Snapshot

integer

The number of snapshots to which the tag is added.

15

ReservedInstance

integer

The number of reserved instances to which the tag is added.

4

LaunchTemplate

integer

The number of launch templates to which the tag is added.

6

Eni

integer

The number of elastic network interfaces (ENIs) to which the tag is added.

5

Disk

integer

The number of disks to which the tag is added.

15

KeyPair

integer

The number of key pairs to which the tag is added.

17

Volume

integer

The number of storage volumes to which the tag is added.

6

Examples

Success response

JSON format

{
  "RequestId": "B04B8CF3-4489-432D-83BA-6F128E4F2295",
  "PageSize": 50,
  "PageNumber": 1,
  "TotalCount": 1,
  "Tags": {
    "Tag": [
      {
        "TagValue": "TestValue",
        "TagKey": "TestKey",
        "ResourceTypeCount": {
          "Instance": 45,
          "Image": 6,
          "Ddh": 1,
          "SnapshotPolicy": 4,
          "Securitygroup": 4,
          "Snapshot": 15,
          "ReservedInstance": 4,
          "LaunchTemplate": 6,
          "Eni": 5,
          "Disk": 15,
          "KeyPair": 17,
          "Volume": 6
        }
      }
    ]
  }
}

Error codes

HTTP status code

Error code

Error message

Description

400 InvalidTagCount The specified tags are beyond the permitted range. The number of specified tags exceeds the upper limit.
400 InvalidTagKey.Malformed The parameter Tag.n.Key is illegal. The specified Tag.N.Key parameter is invalid.
400 InvalidTagValue.Malformed The parameter Tag.n.Value is illegal. The specified Tag.N.Value parameter is invalid.
400 Invalid.TagCategory The parameter Category is illegal.
404 InvalidRegionId.NotFound The specified RegionId does not exist. The specified region ID does not exist.
404 InvalidResourceType.NotFound The ResourceType provided does not exist in our records. The specified resource type does not exist.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.