All Products
Search
Document Center

Virtual Private Cloud:ListTagResources

Last Updated:Aug 21, 2025

Queries the tags that are attached to a VPC peering connection.

Operation description

  • You must specify at least ResourceId.N or Tag.N, which consists of Tag.N.Key and Tag.N.Value, to identify the resources 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 associated with the tag key are returned. Specifying only Tag.N.Value returns an error.

  • If you specify both Tag.N and ResourceId.N, only resources that have all the specified tags and match the specified resource IDs are returned.

  • If you specify multiple tag key-value pairs, only the resources that have all the specified tags are returned.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

vpc:ListTagResources

list

*All Resource

*

None

None

Request parameters

Parameter

Type

Required

Description

Example

ResourceType

string

Yes

The resource type. Valid value: PeerConnection. This value specifies a VPC peering connection.

PeerConnection

ResourceIddeprecated

array

No

The IDs of the resources. You can specify up to 20 resource IDs.

string

No

The ID of the resource. You can specify up to 20 resource IDs.

Note

You must specify at least ResourceId.N or Tag.N (which consists of Tag.N.Key and Tag.N.Value).

pcc-bp16qjewdsunr41m1****

Tagdeprecated

array<object>

No

The tags.

object

No

The tag.

Key

string

No

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

A tag key can be up to 128 characters in length. It cannot start with aliyun or acs:, and cannot contain http:// or https://.

Note

You must specify at least ResourceId.N or Tag.N (which consists of Tag.N.Key and Tag.N.Value).

FinanceDept

Value

string

No

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

A tag value can be up to 128 characters in length. It cannot start with aliyun or acs:, and cannot contain http:// or https://.

Note

You must specify at least ResourceId.N or Tag.N (which consists of Tag.N.Key and Tag.N.Value).

FinanceJoshua

MaxResults

integer

No

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

50

NextToken

string

No

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

  • If this is the first query or no subsequent query is to be sent, do not specify this parameter.

  • To retrieve the next page of results, set this parameter to the NextToken value returned from the previous call.

FFmyTO70tTpLG6I3FmYAXGKPd****

RegionId

string

Yes

The ID of the region where the resource is deployed. See DescribeRegions.

cn-hangzhou

Category

string

No

The type of the tag.

  • All (default)

  • Custom

  • System

All

Response elements

Parameter

Type

Description

Example

object

Request ID.

RequestId

string

Request ID.

DE65F6B7-7566-4802-9007-96F2494AC512

TagResources

array<object>

A list of the resources and their tags.

object

The details of a resource and its tag.

ResourceId

string

The ID of the resource.

pcc-bp16qjewdsunr41m1****

ResourceType

string

The type of the resource. Valid value: PeerConnection, which indicates a VPC peering connection.

PeerConnection

RegionNo

string

The region of the requester VPC of the peering connection.

cn-hangzhou

TagKey

string

The tag key.

FinanceDept

TagValue

string

The tag value.

FinanceJoshua

NextToken

string

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

  • If the returned value is empty, no more results are available.

  • If a value is returned, it is the token for the next query.

FFmyTO70tTpLG6I3FmYAXGKPd****

MaxResults

integer

The number of entries returned per page.

50

Examples

Success response

JSON format

{
  "RequestId": "DE65F6B7-7566-4802-9007-96F2494AC512",
  "TagResources": [
    {
      "ResourceId": "pcc-bp16qjewdsunr41m1****",
      "ResourceType": "PeerConnection",
      "RegionNo": "cn-hangzhou",
      "TagKey": "FinanceDept",
      "TagValue": "FinanceJoshua"
    }
  ],
  "NextToken": "FFmyTO70tTpLG6I3FmYAXGKPd****",
  "MaxResults": 50
}

Error codes

HTTP status code

Error code

Error message

Description

400

InvalidTagKey

The tag keys are not valid.

The tag index is invalid.

400

NumberExceed.Tags

The maximum number of tags is exceeded.

The number of tags has reached the upper limit.

400

NumberExceed.ResourceIds

The maximum number of resource IDs is exceeded.

The number of resource group IDs exceeds the upper limit.

400

Forbidden.TagKeys

The tag key cannot be operated by the request.

You cannot manage the tag key by calling the operation.

400

Forbidden.TagKey.Duplicated

The specified tag key already exists.

The tag resources are duplicate.

400

InvalidInstanceIds.NotFound

The instance IDs are not found.

The instance ID is invalid.

400

InvalidInstanceType.NotFound

The instance type is not found.

The instance type is invalid.

400

BothEmpty.TagsAndResources

The specified Tags and ResourcesIds are not allow to both empty.

The tag and resource information cannot be empty at the same time.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.