The DescribeResourceByTags operation retrieves resources by tag or resource type.
This API has been deprecated. We recommend migrating to Tag(2018-08-28) - ListResourcesByTag for enhanced functionality and continued support. While the deprecated API remains temporarily accessible, no further updates or bug fixes will be provided.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
ecs:DescribeResourceByTags |
get |
*All Resource
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| PageSize |
integer |
No |
The number of entries per page. Maximum value: 100. Default value: 50. |
50 |
| PageNumber |
integer |
No |
The page number to return. The minimum value is 1. Default value: 1. |
1 |
| ResourceType |
string |
No |
The resource type. Valid values:
All values must be in lowercase. |
instance |
| RegionId |
string |
Yes |
The ID of the region where the resource is located. You can call DescribeRegions to view the latest list of Alibaba Cloud regions. |
cn-hangzhou |
| Tag |
array<object> |
No |
The tag list. |
|
|
object |
No |
A tag object. |
||
| key |
string |
No |
The tag key. Note
For best compatibility, we recommend that you use the |
testkey |
| Key |
string |
No |
The tag key. Note
For best compatibility, we recommend that you use the |
TestKey |
| Value |
string |
No |
The tag value. An empty string is allowed. The value can be up to 128 characters in length. |
TestValue |
| value |
string |
No |
The tag value. An empty string is allowed. The value can be up to 128 characters in length. |
testvalue |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| RequestId |
string |
The request ID. |
1C1E5359-71D7-44D8-8FAA-0327B549157X |
| PageSize |
integer |
The number of entries per page. |
50 |
| PageNumber |
integer |
The page number. |
1 |
| TotalCount |
integer |
The total number of resources. |
8 |
| Resources |
object |
||
| Resource |
array<object> |
The information about the resources to which the tags are added. |
|
|
object |
|||
| ResourceType |
string |
The resource type. |
instance |
| ResourceId |
string |
The resource ID. |
i-bp16t2cgmiiy7t1c**** |
| RegionId |
string |
The region ID. |
cn-hangzhou |
Examples
Success response
JSON format
{
"RequestId": "1C1E5359-71D7-44D8-8FAA-0327B549157X",
"PageSize": 50,
"PageNumber": 1,
"TotalCount": 8,
"Resources": {
"Resource": [
{
"ResourceType": "instance",
"ResourceId": "i-bp16t2cgmiiy7t1c****",
"RegionId": "cn-hangzhou"
}
]
}
}
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. |
| 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.