Lists the tags on one or more ECS resources.
Operation description
API
To find specific resources, include at least one of the following parameters in your request.
ResourceId.NTag.N(Tag.N.KeyandTag.N.Value)TagFilter.N
If you specify the following parameter combinations, the API returns only the ECS resources that match all conditions.
Tag.NandResourceId.NTagFilter.NandResourceId.N
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
ecs:ListTagResources |
get |
*All Resource
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| RegionId |
string |
Yes |
The ID of the region where the resource is located. You can call the DescribeRegions operation to view the latest list of Alibaba Cloud regions. |
cn-hangzhou |
| RegionId |
string |
Yes |
|
cn-hangzhou |
| NextToken |
string |
No |
The pagination token to retrieve the next page of results. |
caeba0bbb2be03f84eb48b699f0a4883 |
| ResourceType |
string |
Yes |
The resource type. Valid values:
|
instance |
| ResourceId |
array |
No |
The ID of an ECS resource. The value of N ranges from 1 to 50. |
i-bp1j6qtvdm8w0z1o**** |
|
string |
No |
|
i-bp1j6qtvdm8w0z1o**** |
|
| Tag |
array<object> |
No |
A list of tags. |
|
|
object |
No |
|
||
| Key |
string |
No |
The tag key to use for an exact match. The tag key must be 1 to 128 characters in length. The value of N ranges from 1 to 20. Usage notes for the
|
TestKey |
| Value |
string |
No |
The tag value to use for an exact match. The tag value must be 1 to 128 characters in length. The value of N ranges from 1 to 20. Note
When |
TestValue |
| TagFilter |
array<object> |
No |
A list of tag filters. Note
This parameter is in invitation-only preview and is not yet available. |
|
|
object |
No |
|
||
| TagValues |
array |
No |
The tag values to use for a fuzzy match. The tag value must be 1 to 128 characters in length. The value of N ranges from 1 to 5. For more information, see the description of the |
TestTagFilter |
|
string |
No |
|
TestTagFilter |
|
| TagKey |
string |
No |
The tag key to use for a fuzzy match. The tag key must be 1 to 128 characters in length. The value of N ranges from 1 to 5. Use the
Note
You cannot specify both the |
env |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| NextToken |
string |
The token to retrieve the next page of results. |
caeba0bbb2be03f84eb48b699f0a4883 |
| RequestId |
string |
The request ID. |
484256DA-D816-44D2-9D86-B6EE4D5BA78C |
| TagResources |
object |
||
| TagResource |
array<object> |
An array of tags and their associated resources. Each object in the array contains the resource ID, resource type, tag key, and tag value. |
|
|
object |
|||
| TagValue |
string |
The tag value. |
TestValue |
| ResourceType |
string |
The resource type. Valid values:
|
instance |
| ResourceId |
string |
The resource ID. |
i-bp1j6qtvdm8w0z1o**** |
| TagKey |
string |
The tag key. |
TestKey |
Examples
Success response
JSON format
{
"NextToken": "caeba0bbb2be03f84eb48b699f0a4883",
"RequestId": "484256DA-D816-44D2-9D86-B6EE4D5BA78C",
"TagResources": {
"TagResource": [
{
"TagValue": "TestValue",
"ResourceType": "instance",
"ResourceId": "i-bp1j6qtvdm8w0z1o****",
"TagKey": "TestKey"
}
]
}
}
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 | NumberExceed.ResourceIds | The ResourceIds parameter's number is exceed , Valid : 50. | The number of ResourceIds parameters specified exceeds the limit. |
| 400 | NumberExceed.Tags | The Tags parameter's number is exceed , Valid : 20. | The number of labels specified exceeds the limit. |
| 400 | Duplicate.TagKey | The Tag.N.Key contain duplicate key. | The specified tag key already exists. Tag keys must be unique. |
| 400 | InvalidTagKey.Malformed | The specified Tag.n.Key is not valid. | The specified Tag.N.Key parameter is invalid. |
| 400 | InvalidTagValue.Malformed | The specified Tag.n.Value is not valid. | The specified tag value is invalid. |
| 400 | OperationDenied.QuotaExceed | The quota of tags on resource is beyond permitted range. | |
| 400 | InvalidTag.Mismatch | The specified Tag.n.Key and Tag.n.Value are not match. | The specified Tag.N.Key and Tag.N.Value parameters do not correspond to each other. |
| 400 | InvalidTagCount | The specified tags are beyond the permitted range. | The number of specified tags exceeds the upper limit. |
| 400 | Invalid.Scope | The specified scope is invalid. | |
| 400 | InvalidTags.MalFormed | The tags must be empty, when the tagFilters is not empty. | |
| 500 | ServiceUnavailable | The service is unavailable, please try again later. | |
| 500 | InternalError | The process of creating snapshot has failed due to some unknown error. | The snapshot cannot be created. |
| 403 | PermissionDenied.TagOwnerBid | The specified operator not have permission to set TagOwnerBid 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. | |
| 403 | NoPermission.Tag | The operator is not permission for the tag. | You are not authorized to manage the tag. |
| 403 | BothEmpty.TagsAndResources | The specified Tags and ResourcesIds are not allow to both empty. | The parameter passed in must contain Tags or |
| 403 | PermissionDenied.TagsFuzzyQuery | The specified operator has not permission to query fuzzy tags. | |
| 403 | NumberExceed.TagValues | The number of the specified TagValues is beyond permitted range, the max is 5. | |
| 403 | InvalidFilter.Malformed | The specified Filter is not valid. | |
| 403 | InvalidTagFilter.Malformed | The specified TagFilter is not valid. | |
| 403 | Invalid.NextToken | The specified NextToken is not valid. | |
| 404 | InvalidRegionId.NotFound | The RegionId provided does not exist in our records. | Region information error |
| 404 | MissingParameter.ResourceIds | The parameter - ResourceIds.N should not be null. | |
| 404 | MissingParameter.TagOwnerUid | The parameter - TagOwnerUid should not be null. | |
| 404 | MissingParameter.TagOwnerBid | The parameter - TagOwnerBid should not be null. | |
| 404 | MissingParameter.ResourceType | The parameter - ResourceType should not be null. | The ResourceType parameter is required. |
| 404 | MissingParameter.Tags | The parameter - Tags should not be null. | |
| 404 | MissingParameter.RegionId | The parameter - RegionId should not be null. | |
| 404 | InvalidResourceId.NotFound | The specified ResourceIds are not found in our records. | The specified resource does not exist. Check whether the ResourceId parameter is correct. |
| 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.