Queries the tags that are added to Elastic Compute Service (ECS) resources.
Usage notes
Specify at least one of the following parameters or parameter pairs in a request to determine a query object:
ResourceId.NTag.Nparameter pair (Tag.N.KeyandTag.N.Value)TagFilter.N
If one of the following sets of request parameters is specified as filter conditions, only ECS resources that meet all the specified filter conditions are returned:
- Set 1:
Tag.N.Key, Tag.N.Value, andResourceId.N - Set 2:
TagFilter.N.TagKey, TagFilter.N.TagValues.N, andResourceId.N
Debugging
Request parameters
|
Parameter |
Type |
Required |
Example |
Description |
| Action | String | Yes | ListTagResources | The operation that you want to perform. Set the value to ListTagResources. |
| RegionId | String | Yes | cn-hangzhou | The region ID of the resource. You can call the DescribeRegions operation to query the most recent region list. |
| NextToken | String | No | caeba0bbb2be03f84eb48b699f0a4883 | A pagination token. |
| ResourceType | String | Yes | instance | The type of the resource. Valid values:
|
| ResourceId.N | String | No | i-bp1j6qtvdm8w0z1o**** | The ID of resource N. Valid values of N: 1 to 50. |
| Tag.N.Key | String | No | TestKey | The key of tag N used for exact search of ECS resources. The tag key must be 1 to 128 characters in length. Valid values of N: 1 to 20. Methods of using the
|
| Tag.N.Value | String | No | TestValue | The value of tag N used for exact search of ECS resources. The tag value must be 1 to 128 characters in length. Valid values of N: 1 to 20. Note When Tag.1.Key is set to acs:rm:rgId, you can set Tag.1.Value only to the ID of a non-default resource group. |
| TagFilter.N.TagValues.N | String | No | TestTagFilter | The value of tag N used for fuzzy search of ECS resources. The tag value must be 1 to 128 characters in length. Valid values of N: 1 to 5. For more information, see the description of |
| TagFilter.N.TagKey | String | No | env | The key of tag N used for fuzzy search of ECS resources. The tag key must be 1 to 128 characters in length. Valid values of N: 1 to 5. The
Note The TagFilter.N parameter pair (TagFilter.N.TagKey and TagFilter.N.TagValues.N) cannot be used together with the Tag.N parameter pair (Tag.N.Key and Tag.N.Value). Otherwise, an error message is returned. |
Response parameters
Parameter |
Type |
Example |
Description |
| NextToken | String | caeba0bbb2be03f84eb48b699f0a4883 | The token that is required for the next query. |
| RequestId | String | 484256DA-D816-44D2-9D86-B6EE4D5BA78C | The ID of the request. |
| TagResources | Array of TagResource | Details about the resources and tags, including resource IDs, resource types, and tag key-value pairs. |
|
| TagResource | |||
| TagValue | String | TestValue | The tag value of the resource. |
| ResourceType | String | instance | The resource type. Valid values:
|
| ResourceId | String | i-bp1j6qtvdm8w0z1o**** | The resource ID. |
| TagKey | String | TestKey | The tag key. |
Examples
Sample requests
http(s)://ecs.aliyuncs.com/?Action=ListTagResources
&RegionId=cn-hangzhou
&ResourceType=instance
&ResourceId.1=i-bp1j6qtvdm8w0z1o****
&<Common request parameters>
Sample success responses
XML format
HTTP/1.1 200 OK
Content-Type:application/xml
<ListTagResourcesResponse>
<TagResources>
<TagResource>
<ResourceType>instance</ResourceType>
<TagValue>TestValue</TagValue>
<ResourceId>i-bp1j6qtvdm8w0z1o****</ResourceId>
<TagKey>TestKey</TagKey>
</TagResource>
</TagResources>
<RequestId>DE65F6B7-7566-4802-9007-96F2494AC512</RequestId>
</ListTagResourcesResponse>
JSON format
HTTP/1.1 200 OK
Content-Type:application/json
{
"TagResources" : {
"TagResource" : [ {
"ResourceType" : "instance",
"TagValue" : "TestValue",
"ResourceId" : "i-bp1j6qtvdm8w0z1o****",
"TagKey" : "TestKey"
} ]
},
"RequestId" : "DE65F6B7-7566-4802-9007-96F2494AC512"
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
| 400 | InvalidDefaultResourceGroup.NotSupported | The specified parameter Tag is not support for default resource group. | The default resource group cannot be queried. |
| 400 | InvalidTag.NotSupported | You can only specify Tag for either resource tag or resource group. | Resource groups and tags cannot be queried at the same time. |
| 400 | Duplicate.TagKey | The Tag.N.Key contain duplicate key. | The tag key already exists. Tag keys must be unique. |
| 400 | InvalidTagKey.Malformed | The specified Tag.n.Key is not valid. | Invalid Tag.N.Key value. |
| 400 | InvalidTagValue.Malformed | The specified Tag.n.Value is not valid. | Invalid Tag.N.Value value. |
| 400 | OperationDenied.QuotaExceed | The quota of tags on resource is beyond permitted range. | The maximum number of tags is exceeded. |
| 400 | InvalidTag.Mismatch | The specified Tag.n.Key and Tag.n.Value are not match. | The Tag.N.Key and Tag.N.Value values do not correspond to each other. |
| 400 | InvalidTagCount | The specified tags are beyond the permitted range. | The maximum number of tags is exceeded. |
| 400 | Invalid.Scope | The specified scope is invalid. | Invalid Scope value. |
| 403 | PermissionDenied.TagOwnerUid | The specified operator not have permission to set TagOwnerUid value. | You are not authorized to specify the TagOwnerUid parameter. |
| 403 | PermissionDenied.Scope | The specified operator not have permission to set Scope value. | You are not authorized to specify the Scope parameter. |
| 403 | InvalidResourceId.NotSupported | The specified ResourceId does not support tagging. | The specified resource does not support tagging. |
| 403 | NoPermission.Tag | The operator is not permission for the tag. | You are not authorized to manage the tag. |
| 404 | InvalidRegionId.NotFound | %s | The specified region ID is not found. |
| 404 | MissingParameter.ResourceType | The parameter - ResourceType should not be null. | ResourceType is required. |
| 404 | InvalidResourceId.NotFound | The specified ResourceIds are not found in our records. | The specified resource ID is not found. Check whether the resource ID is correct. |
| 404 | InvalidResourceType.NotFound | The ResourceType provided does not exist in our records. | The specified resource type is not found. |
| 404 | InvalidRegionId.NotFound | The specified RegionId does not exist. | Invalid RegionId value. |
| 500 | ServiceUnavailable | The service is unavailable, please try again later. | The service is temporarily unavailable. Try again later. |
| 500 | InternalError | The process of creating snapshot has failed due to some unknown error. | The snapshot cannot be created. |
For a list of error codes, see Service error codes.