Creates tags and adds them to a virtual private cloud (VPC) peering connection.
Usage notes
Tags are used to classify instances. Each tag consists of a key-value pair. Before you use tags, take note of the following limits:
- The keys of tags that are added to the same instance must be unique.
- You cannot create tags without adding them to instances. All tags must be added to instances.
-
Tag information is not shared across regions.
For example, you cannot view the tags that are created in the China (Hangzhou) region from the China (Shanghai) region.
-
For the same account and region, tags added to different VPC peering connections are shared.
For example, if a tag is added to a VPC peering connection, the tag can also be added to other VPC peering connections within the same account and region. You can modify the key and the value of a tag or remove a tag from an instance. After you delete an instance, all tags that are added to the instance are deleted.
- You can add up to 20 tags to each instance. Before you add a tag to an instance, the system automatically checks the number of existing tags. An error message is returned if the maximum number of tags is reached.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | TagResources | The operation that you want to perform. Set the value to TagResources. |
ResourceId.N | String | No | pcc-bp16qjewdsunr41m1**** | The ID of the resource. You can specify at most 20 IDs. |
Tag.N.Key | String | No | FinanceDept | The key of the tag. You must enter at least one tag key and at most 20 tag keys. The tag key cannot be an empty string. The key cannot exceed 64 characters in length, and can contain digits, periods (.), underscores (_), and hyphens (-). The key must start with a letter but cannot start with |
Tag.N.Value | String | No | FinanceJoshua | The value of the tag. You must enter at least one tag value and at most 20 tag values. It can be an empty string. The tag value cannot exceed 128 characters in length, and can contain digits, periods (.), underscores (_), and hyphens (-). It must start with a letter but cannot start with |
ResourceType | String | Yes | PeerConnection | The type of the resource. Set the value to PeerConnection, which specifies a VPC peering connection. |
ClientToken | String | No | 123e4567-e89b-12d3-a456-426655440000 | The client token that is used to ensure the idempotence of the request. You can use the client to generate the token, but you must make sure that the token is unique among all requests. The token can contain only ASCII characters. Note If you do not specify this parameter, ClientToken is set to the value of RequestId. The value of RequestId for each API request may be different. |
RegionId | String | Yes | cn-hangzhou | The region ID of the resource to which you want to create and add tags. You can call the DescribeRegions operation to query the most recent region list. |
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
RequestId | String | C46FF5A8-C5F0-4024-8262-B16B639225A0 | The ID of the request. |
Success | Boolean | true | Indicates whether the operation is successful. Valid values:
|
Examples
Sample requests
http(s)://[Endpoint]/?Action=TagResources
&ResourceId=["pcc-bp16qjewdsunr41m1****"]
&Tag=[{"Key":"FinanceDept","Value":"FinanceJoshua"}]
&ResourceType=PeerConnection
&ClientToken=123e4567-e89b-12d3-a456-426655440000
&RegionId=cn-hangzhou
&Common request parameters
Sample success responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<TagResourcesResponse>
<RequestId>C46FF5A8-C5F0-4024-8262-B16B639225A0</RequestId>
<Success>true</Success>
</TagResourcesResponse>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "C46FF5A8-C5F0-4024-8262-B16B639225A0",
"Success" : true
}
Error codes
HttpCode | Error code | Error message | Description |
---|---|---|---|
400 | NumberExceed.Tags | The maximum number of tags is exceeded. | The error message returned because the number of tags exceeds the upper limit. |
400 | NumberExceed.ResourceIds | The maximum number of resource IDs is exceeded. | The error message returned because the specified number of resource group IDs exceeds the upper limit. |
400 | Forbidden.TagKeys | The tag key cannot be operated by the request. | The error message returned because you cannot manage the tag key by calling the operation. |
400 | Forbidden.TagKey.Duplicated | The specified tag key already exists. | The error message returned because the tag key already exists. |
400 | InvalidInstanceIds.NotFound | The instance IDs are not found. | The error message returned because the instance ID is not found. |
400 | InvalidInstanceType.NotFound | The instance type is not found. | The error message returned because the instance type is not found. |
For a list of error codes, see Service error codes.