All Products
Search
Document Center

Virtual Private Cloud:DescribeTags

Last Updated:Aug 29, 2024

Queries tags that meet the specified filter conditions.

Operation description

  • You must specify ResourceId.N or Tag.N that consists of Tag.N.Key and Tag.N.Value in the request to specify the object that you want to query.
  • Tag.N is a resource tag that consists of a key-value pair. If you specify only Tag.N.Key, all tag values that are associated with the specified tag key are returned. If you specify only Tag.N.Value, an error message is returned.
  • If you specify Tag.N and ResourceId.N to filter tags, ResourceId.N must match all specified key-value pairs.
  • If you specify multiple key-value pairs, all tags that match the key-value pairs are returned.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
vpc:DescribeTagsget
  • All Resources
    *
  • vpc:tag
none

Request parameters

ParameterTypeRequiredDescriptionExample
ResourceTypestringNo

The resource type. Valid values:

  • VPC: virtual private cloud (VPC)
  • VSWITCH: vSwitch
  • ROUTETABLE: route table
  • EIP: elastic IP address (EIP)
  • VpnGateway: VPN gateway
  • NATGATEWAY: NAT gateway
  • COMMONBANDWIDTHPACKAGE: EIP bandwidth plan
VPC
RegionIdstringYes

The ID of the region to which the resource belongs.

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

cn-hangzhou
NextTokenstringNo

The token that is used for the next query. Valid values:

  • If this is your first query or no next query is to be sent, ignore this parameter.
  • If a subsequent query is to be sent, set the parameter to the value of NextToken that is returned from the last call.
FFmyTO70tTpLG6I3FmYAXGKPd****
MaxResultintegerNo

The number of entries to return on each page. Valid values: 1 to 50. Default value: 50.

50
ResourceIdarrayNo
stringNo

The ID of the resource. You can enter at most 50 IDs.

Note If you set this parameter, you must set ResourceType.
vpc-bp16qjewdsunr41m1****
Tagarray<object>No
objectNo
KeystringNo

The key of the tag that is added to the resource. You can specify up to 20 tag keys. The tag key cannot be an empty string.

The key cannot exceed 64 characters in length, and can contain digits, periods (.), underscores (_), and hyphens (-). The key must start with a letter but cannot start with aliyun or acs:. The key cannot contain http:// or https://.

FinanceDept
ValuestringNo

The value of the tag that is added to the resource. You can specify up to 20 tag values. The tag value can be an empty string.

The tag value cannot exceed 128 characters in length, and can contain digits, periods (.), underscores (_), and hyphens (-). The key must start with a letter but cannot start with aliyun or acs:. The key cannot contain http:// or https://.

FinanceJoshua

Response parameters

ParameterTypeDescriptionExample
object

object

NextTokenstring

The token that is used for the next query. Valid values:

  • If the value of NextToken is not returned, it indicates that no next query is to be sent.
  • If a value of NextToken is returned, the value is the token that is used for the subsequent query.
FFmyTO70tTpLG6I3FmYAXGKPd****
RequestIdstring

The ID of the request.

C46FF5A8-C5F0-4024-8262-B16B639225A0
TagResourcesarray<object>

The list of tags that meet the filter conditions.

object
TagValuestring

The tag value.

FinanceJoshua
TagKeystring

The tag key.

FinanceDept

Examples

Sample success responses

JSONformat

{
  "NextToken": "FFmyTO70tTpLG6I3FmYAXGKPd****",
  "RequestId": "C46FF5A8-C5F0-4024-8262-B16B639225A0",
  "TagResources": {
    "TagResource": [
      {
        "TagValue": "FinanceJoshua",
        "TagKey": "FinanceDept"
      }
    ]
  }
}

Error codes

HTTP status codeError codeError messageDescription
400BothEmpty.TagsAndResourcesThe specified Tags and ResourcesIds are not allow to both empty.The tags and resource groups cannot be empty at the same time.
400MissingParameter.TagKeyThe input parameter TagKey that is mandatory for processing this request is not supplied.The TagKey parameter is not set.
400MissingParameter.TagValueThe input parameter TagValue that is mandatory for processing this request is not supplied.The TagValue parameter is not set.
400InvalidTagKeyThe tag keys are not valid.The tag index is invalid.
400InvalidTagValueThe tag values are not valid.The tag value is invalid.
400MissingParam%s-
400InvalidInstanceType.NotFoundThe instance type is not foundThe instance type is not found.
400InvalidInstanceIds.NotFoundThe instanceIds are not foundThe instance ID is not found.
400Forbidden.TagKeysThe request do not allow to operate the tag keysYou do not have the permissions to set the TagKeys parameter.
400QuotaExceeded.TagNumCustom Tags quota exceededThe upper limit is reached.
400Forbidden.NotAllowedCategaryThe System tag is not validThe error message returned because the system tag is invalid.
400Forbidden.TagKeysThe request does not allow operate this tagkeysThe error message returned because you cannot manage the tag key by calling the operation.
400Forbidden.TagKey.DuplicatedThe specified tag key already exists.The tag resources are duplicate.
400SizeLimitExceeded.TagNumThe maximum number of tags is exceeded.The number of tags has reached the upper limit.
400SizeLimitExceeded.ResourceIdThe maximum number of resource IDs is exceeded.The number of resource group IDs has reached the upper limit.
403ForbiddenUser not authorized to operate on the specified resource.You do not have the permissions to manage the specified resource. Apply for the permissions and try again.

For a list of error codes, visit the Service error codes.