Creates and adds tags to specified Auto Scaling resources.
Description
- You can add up to 20 tags to a scaling group.
- Before you add tags to a scaling group, Auto Scaling automatically checks the number of existing tags of the scaling group. If the maximum number is exceeded, an error message is returned when you call the operation.
- If you set the
Propagate
parameter totrue
, the tags that you add to a scaling group are propagated only to instances that are pending to be added to the scaling group. The tags are not propagated to instances that are already running in the scaling group. - If you add tags to a scaling group and set the Propagate parameter to true, the following
rules apply:
- The tags of instances that are pending to be added to the scaling group include the following tags: tags that are specified in the scaling configuration based on which the instances are created and tags that are added to the scaling group and propagated to the instances.
- If the tags that are specified in the scaling configuration and the tags that are added to the scaling group and propagated to the instances have the same tag keys, the tags that are added to the scaling group and propagated to the instances are overwritten by the tags that are specified in the scaling configuration.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | TagResources |
The operation that you want to perform. Set the value to TagResources. |
RegionId | String | Yes | cn-hangzhou |
The region ID of the resource. You can call the DescribeRegions operation to query the most recent region list. |
ResourceType | String | Yes | scalinggroup |
The type of the resource. Only scaling groups are supported. Set the value to scalinggroup. |
ResourceId.N | String | Yes | asg-2zej7nf7hea77k5a**** |
The ID of resource N. Valid values of N: 1 to 50. |
Tag.N.Key | String | No | TestKey |
The key of tag N. Valid values of N: 1 to 20. The tag key cannot be an empty string. The tag key can be up to 128 characters in
length and cannot start with |
Tag.N.Value | String | No | TestValue |
The value of tag N. Valid values of N: 1 to 20. The tag value can be an empty string. The tag value can be up to 128 characters in
length and cannot start with |
Tag.N.Propagate | Boolean | No | false |
Specifies whether tag N can be propagated. Valid values:
Default value: false. |
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
RequestId | String | 74C4E313-8570-479F-8791-DC25360D**** |
The ID of the request. |
Examples
Sample requests
http(s)://ess.aliyuncs.com/?Action=TagResources
&RegionId=cn-hangzhou
&ResourceType=scalinggroup
&ResourceId=["asg-2zej7nf7hea77k5a****"]
&Tag=[{"Key":"TestKey","Value":"TestValue","Propagate":false}]
&<Common request parameters>
Sample success responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<TagResourcesResponse>
<RequestId>74C4E313-8570-479F-8791-DC25360D****</RequestId>
</TagResourcesResponse>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "74C4E313-8570-479F-8791-DC25360D****"
}
Error codes
For a list of error codes, visit the API Error Center.