You can call the TagResources operation to create and add tags to instances.
Operation Description
If you have a large number of instances, you can create multiple tags and add these tags to the instances. Then, you can filter these instances by tag.
- A tag consists of a key and a value. Each key must be unique in a region for an Alibaba Cloud account. Different keys can be mapped to the same value.
- If the tag that you specify does not exist, this tag is automatically created and added to the specified instance.
- If the key of the specified tag is the same as that of an existing tag, the specified tag overwrites the existing tag.
- You can add up to 20 tags to an instance.
- You can add tags to up to 50 instances in each call.
Authorization information
The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action
policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:
- Operation: the value that you can use in the Action element to specify the operation on a resource.
- Access level: the access level of each operation. The levels are read, write, and list.
- Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
- The required resource types are displayed in bold characters.
- If the permissions cannot be granted at the resource level,
All Resources
is used in the Resource type column of the operation.
- Condition Key: the condition key that is defined by the cloud service.
- Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
Operation | Access level | Resource type | Condition key | Associated operation |
---|---|---|---|---|
rds:TagResources | WRITE |
|
| none |
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
RegionId | string | Yes | The ID of the region. You can call the DescribeRegions operation to query the most recent region list. | cn-hangzhou |
ResourceType | string | Yes | The type of the resource. Set the value to INSTANCE. | INSTANCE |
ResourceId | array | Yes | The IDs of the instances. You can specify up to 50 instance IDs. | |
string | No | The IDs of the instances. You can add tags to N instances at a time. Valid values of N: 1 to 50. | rm-uf6wjk5xxxxxxx | |
Tag | object [] | No | The tags to be added to the resources. You can specify up to 20 tags. | |
Key | string | Yes | The key of the tag that you want to add to the instance. The value of this parameter cannot be an empty string. | testkey1 |
Value | string | No | The tag value that is associated with the specified tag key. This parameter can be an empty string. | testvalue1 |
Response parameters
Examples
Sample success responses
JSON
format
{
"RequestId": "224DB9F7-3100-4899-AB9C-C938BCCB43E7"
}
Error codes
HTTP status code | Error code | Error message | Description |
---|---|---|---|
400 | NumberExceed.Tags | The maximum number of Tags is exceeded. The maximum value is 20. | The maximum number of Tags is exceeded. The maximum value is 20. |
400 | MissingParameter | The parameter - ResourceIds.N should not be null | - |
400 | MissingParameter | The parameter - Tags should not be null | You must specify Tag.N.Key. |
400 | InvalidTagKey.Malformed | The Tag.N.Key parameter is blank | The operation failed. The Tag.N.Key parameter is empty. |
400 | InvalidTagValue.Malformed | The Tag.N.Value parameter is blank | The Tag.N.Value is empty. |
400 | Duplicate.TagKey | The Tag.N.Key contain duplicate key. | The operation failed. A duplicate key is specified by the Tag.N.Key parameter. |
400 | OperationDenied.QuotaExceed | The maximum number of Tags is exceeded. | The maximum number of Tags is exceeded. |
400 | NumberExceed.ResourceIds | The maximum number of ResourceIds is exceeded. The maximum value is 50. | The maximum number of ResourceIds is exceeded. The maximum value is 50. |
400 | InvalidTagKey.Malformed | The operator is not permission for the system tag | The operation failed. You do not have permissions on system tags. |
400 | Request.NotFound | The requested resource is not available. | The requested resources are unavailable. |
400 | InvalidTagValue.Malformed | The Tag.N.Value parameter is invalid. | The Tag.N.Value parameter is invalid. |
For a list of error codes, visit the Service error codes.
Change history
Change time | Summary of changes | Operation | ||||||
---|---|---|---|---|---|---|---|---|
2022-06-23 | API Description Update,The error codes of the API operation change. | |||||||
|