All Products
Search
Document Center

Auto Scaling:TagResources

Last Updated:May 21, 2024

Creates and attaches tags. You can call the TagResources operation to uniformly create and attach tags to your Auto Scaling resources, streamlining resource management. This capability empowers you to categorize resources based on tags, thereby enhancing the overall efficiency of resource allocation and utilization.

Usage notes

  • You can attach up to 20 tags to a scaling group.

    Note

    Before you attach tags to a specific Auto Scaling resource, Alibaba Cloud automatically verifies the current number of tags attached to that resource. In the event the proposed addition would exceed the maximum allowed number of tags, an error message will be promptly returned after you call this operation.

  • If you set Tag.N.Propagate to true, any tags attached to your scaling group will be automatically propagated to new instances that are subsequently created within the group, without affecting existing instances.

  • If both the scaling configuration and the scaling group have tags attached, and tag propagation from the scaling group is enabled, the tags of newly created instances comply with the following rules:

    • Instances set to join the scaling group will inherit the following tags: tags attached to the scaling configuration that initiates the instance creation and tags attached to the scaling group that are allowed to propagate to these instances upon creation.

    • If the tag keys of the scaling configuration and those attached to the scaling group and propagated to the instances are identical, the tags attached to the scaling group and propagated to the instances will be overwritten by the tags of the scaling configuration.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

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 resource type. Set the value to scalinggroup.

ResourceId.N

String

No

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 value of this parameter cannot be an empty string. The tag key can be up to 128 characters in length. It cannot contain http:// or https://, and cannot start with acs: or aliyun.

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 contain http:// or https://.

Tag.N.Propagate

Boolean

No

false

Specifies whether tag N can be propagated. Valid values:

  • true: Tag N can be propagated only to instances that are set to join the scaling group, without affecting the existing instances in the scaling group.

  • false: Tag N cannot be propagated to any instances.

Default value: false.

Response parameters

Parameter

Type

Example

Description

RequestId

String

74C4E313-8570-479F-8791-DC25360D****

The request ID.

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, see Service error codes.