All Products
Search
Document Center

Resource Management:ListResourcesByTag

Last Updated:Mar 03, 2024

Queries resources to which a specified tag is added or resources to which a specified tag is not added.

Operation description

This topic provides an example on how to call the API operation in the China (Shenzhen) region to query virtual private clouds (VPCs) to which the tag key k1 is added. The response shows that the tag key is added to two VPCs.

Debugging

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

Authorization information

There is currently no authorization information disclosed in the API.

Request parameters

ParameterTypeRequiredDescriptionExample
RegionIdstringYes

The region ID.

For more information about region IDs, see Endpoints .

cn-shenzhen
NextTokenstringNo

The token that is used to start the next query.

caeba0bbb2be03f84eb48b699f0a****
MaxResultintegerNo

The number of entries to return on each page.

Default value: 50. Maximum value: 1000.

50
ResourceTypestringYes

The resource type. This parameter specifies a filter condition for the query.

  • If you set the FuzzyType parameter to EQUAL, you can set this parameter to a value obtained from the response of the ListSupportResourceTypes operation.
  • If you set the FuzzyType parameter to NOT, you can set this parameter to a resource type provided in Types of resources that support queries based on the NOT operator.
ALIYUN::VPC::VPC
FuzzyTypestringNo

The type of the query. Valid values:

  • EQUAL: exact match for resources to which the specified tag is added. This is the default value.
  • NOT: exact match for resources to which the specified tag is not added.
EQUAL
TagFilter.ValuestringNo

The tag value. This parameter specifies a filter condition for the query.

The tag value can be a maximum of 128 characters in length. It cannot contain http:// or https://.

v1
TagFilter.KeystringYes

The tag key. This parameter specifies a filter condition for the query.

The tag key can be a maximum of 128 characters in length. It cannot contain http:// or https:// and cannot start with acs: or aliyun.

k1
IncludeAllTagsbooleanNo

Specifies whether to return the information of tags added to the resources. Valid values:

  • False: does not return the information of tags added to the resources. This is the default value.
  • True: returns the information of all tags added to the resources.
False

Types of resources that support queries based on the NOT operator:

  • ALIYUN::ADB::CLUSTER
  • ALIYUN::ALB::ACL
  • ALIYUN::ALB::LOADBALANCER
  • ALIYUN::ALB::SECURITYPOLICY
  • ALIYUN::ALB::SERVERGROUP
  • ALIYUN::ALIDNS::DOMAIN
  • ALIYUN::BASTIONHOST::INSTANCE
  • ALIYUN::BPSTUDIO::APPLICATION
  • ALIYUN::BPSTUDIO::TEMPLATE
  • ALIYUN::CAS::INSTANCE
  • ALIYUN::CDN::DOMAIN
  • ALIYUN::CDS::CLUSTER
  • ALIYUN::CEN::BANDWIDTHPACKAGE
  • ALIYUN::CEN::CEN
  • ALIYUN::CS::CLUSTER
  • ALIYUN::DBAUDIT::INSTANCE
  • ALIYUN::DCDN::DOMAIN
  • ALIYUN::DDOSBGP::INSTANCE
  • ALIYUN::DDOSCOO::INSTANCE
  • ALIYUN::DDS::INSTANCE
  • ALIYUN::DRDS::INSTANCE
  • ALIYUN::ECS::DDH
  • ALIYUN::ECS::DDHCLUSTER
  • ALIYUN::ECS::DISK
  • ALIYUN::ECS::ENI
  • ALIYUN::ECS::INSTANCE
  • ALIYUN::ECS::KEYPAIR
  • ALIYUN::ECS::LAUNCHTEMPLATE
  • ALIYUN::ECS::SECURITYGROUP
  • ALIYUN::ECS::SNAPSHOT
  • ALIYUN::EDAS::APPLICATION
  • ALIYUN::EDAS::CLUSTER
  • ALIYUN::ELASTICSEARCH::INSTANCE
  • ALIYUN::EMR::CLUSTER
  • ALIYUN::EMR::FLOWPROJECT
  • ALIYUN::HBR::CLIENT
  • ALIYUN::HBR::HANAINSTANCE
  • ALIYUN::HBR::VAULT
  • ALIYUN::KVSTORE::INSTANCE
  • ALIYUN::MULTIMOD::CLUSTER
  • ALIYUN::OCEANBASE::INSTANCE
  • ALIYUN::OOS::EXECUTION
  • ALIYUN::OOS::PARAMETER
  • ALIYUN::OOS::SECRETPARAMETER
  • ALIYUN::OOS::STATECONFIGURATION
  • ALIYUN::OOS::TEMPLATE
  • ALIYUN::OSS::BUCKET
  • ALIYUN::OUTBOUNDBOT::INSTANCE
  • ALIYUN::POLARDB::CLUSTER
  • ALIYUN::PVTZ::ZONE
  • ALIYUN::RDS::INSTANCE
  • ALIYUN::VPC::COMMONBANDWIDTHPACKAGE
  • ALIYUN::VPC::EIP
  • ALIYUN::VPC::NATGATEWAY
  • ALIYUN::VPC::VPC

Response parameters

ParameterTypeDescriptionExample
object

The response parameters.

RequestIdstring

The ID of the request.

7D61FF74-61C2-5768-B01F-05FC97F24F35
NextTokenstring

Indicates whether the next query is required.

  • If the value of this parameter is empty ("NextToken": ""), all results are returned, and the next query is not required.
  • If the value of this parameter is not empty, the next query is required, and the value is the token used to start the next query.
caeba0bbb2be03f84eb48b699f0a****
Resourcesobject []

The information of the resources.

ResourceIdstring

The ID of the resource.

vpc-wz9pifyuw26esxd05****
Tagsobject []

The information of the tags.

This parameter is returned only if the IncludeAllTags parameter is set to True.

Keystring

The tag key.

k1
Valuestring

The tag value.

v1
Categorystring

The type of the tag. Valid values:

  • custom
  • system
custom

Examples

Sample success responses

JSONformat

{
  "RequestId": "7D61FF74-61C2-5768-B01F-05FC97F24F35",
  "NextToken": "caeba0bbb2be03f84eb48b699f0a****",
  "Resources": [
    {
      "ResourceId": "vpc-wz9pifyuw26esxd05****",
      "Tags": [
        {
          "Key": "k1",
          "Value": "v1",
          "Category": "custom"
        }
      ]
    }
  ]
}

Error codes

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

Change history

Change timeSummary of changesOperation
2022-12-06The internal configuration of the API is changed, but the call is not affectedsee changesets
Change itemChange content
The internal configuration of the API is changed, but the call is not affected.
2022-11-21The internal configuration of the API is changed, but the call is not affectedsee changesets
Change itemChange content
The internal configuration of the API is changed, but the call is not affected.