Attaches vServer groups to a scaling group. After a Classic Load Balancer (CLB) instance is attached to your scaling group, the instances in the scaling group are automatically added as backend servers of the CLB instance. These servers then handle requests forwarded by the CLB instance, streamlining the processing of incoming traffic. To direct varying access requests to separate backend servers or to distribute requests based on domain names or URLs, you can call the AttachVServerGroups operation. This operation enables the addition of multiple vServer groups, allowing for efficient management of various backend server configurations tailored to your routing preferences.
Usage notes
Before you call this operation to attach vServer groups to your scaling group, make sure that the following requirements are met:
The CLB instance and the scaling group belong to the same Alibaba Cloud account.
The CLB instance and the scaling group reside in the same region.
The CLB instance is in the Running state.
The CLB instance is configured with at least one listener. The health check feature is enabled for the CLB instance.
If the network type of both the CLB instance and the scaling group is virtual private cloud (VPC), they use the same VPC.
If the network type of the scaling group is VPC and the network type of the CLB instance is classic network, any backend server of the CLB instance within a VPC setup shares the same VPC as the scaling group.
The vServer groups that you want to attach to the scaling group belong to the CLB instance.
The operation to attach vServer groups does not result in the total number of vServer groups exceeding the predefined quota limit. For information about the vServer group quota, see "Limits".
When you call this operation to attach vServer groups, you must specify the following parameters:
LoadBalancerId: the ID of the CLB instance
VServerGroupId: the ID of the vServer group
Port: the port number of the vServer group.
NoteIf you attempt to attach the same vServer group to a scaling group multiple times over the identical port, the system regards each attempt as a separate vServer group attachment to the scaling group. In your request, if you include the same vServer group ID coupled with the same port number multiple times, only the first configuration of the vServer group and port number pairing is considered valid. Subsequent vServer group and port number parings are disregarded.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
Action | String | Yes | AttachVServerGroups | The operation that you want to perform. Set the value to AttachVServerGroups. |
RegionId | String | Yes | cn-hangzhou | The region ID of the scaling group. Examples: cn-hangzhou and cn-shanghai. For information about regions and zones, see Regions and zones. |
ScalingGroupId | String | Yes | asg-bp18p2yfxow2dloq**** | The ID of the scaling group. |
ClientToken | String | No | 123e4567-e89b-12d3-a456-42665544**** | 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 different requests. The token can contain only ASCII characters and cannot exceed 64 characters in length. For more information, see Ensure idempotence. |
ForceAttach | Boolean | No | false | Specifies whether to add the existing Elastic Compute Service (ECS) instances or elastic container instances in the scaling group to the new vServer group.
Default value: false. |
VServerGroup.N.VServerGroupAttribute.N.VServerGroupId | String | No | rsp-bp1jp1rge**** | The ID of the vServer group. The two Ns in the parameter name respectively denote the following meanings:
|
VServerGroup.N.VServerGroupAttribute.N.Weight | Integer | No | 100 | The weight of an ECS instance or elastic container instance as a backend server in the new vServer group. Valid values: 0 to 100. The two Ns in the parameter name respectively denote the following meanings:
Default value: 50. |
VServerGroup.N.VServerGroupAttribute.N.Port | Integer | No | 22 | The port number over which Auto Scaling adds ECS instances or elastic container instances to the new vServer group. Valid values: 1 to 65535. The two Ns in the parameter name respectively denote the following meanings:
|
VServerGroup.N.LoadBalancerId | String | No | lb-bp1u7etiogg38yvwz**** | The ID of CLB instance N to which the vServer group belongs. N specifies the serial number of the CLB instance. Valid values of N: 1 to 5. |
Response parameters
Parameter | Type | Example | Description |
RequestId | String | 473469C7-AA6F-4DC5-B3DB-A3DC0DE3**** | The request ID. |
Examples
Sample requests
http(s)://ess.aliyuncs.com/?Action=AttachVServerGroups
&RegionId=cn-hangzhou
&ScalingGroupId=asg-bp18p2yfxow2dloq****
&ClientToken=123e4567-e89b-12d3-a456-42665544****
&ForceAttach=false
&VServerGroup=[{"VServerGroupAttribute":[{"VServerGroupId":"rsp-bp1jp1rge****","Weight":100,"Port":22}],"LoadBalancerId":"lb-bp1u7etiogg38yvwz****"}]
&<Common request parameters>
Sample success responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<AttachVServerGroupsResponse>
<RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE3****</RequestId>
</AttachVServerGroupsResponse>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****"
}
Error codes
For a list of error codes, see Service error codes.
HTTP status code | Error code | Error message | Description |
403 | Forbidden.Unauthorized | A required authorization for the specified action is not supplied. | Auto Scaling is not authorized to call the specified operation. |
404 | InvalidScalingGroupId.NotFound | The specified scaling group does not exist. | The specified scaling group does not exist within the Alibaba Cloud account. |
404 | InvalidLoadBalancerId.NotFound | The load balancer "%s" does not exist. | The specified CLB instance does not exist within the Alibaba Cloud account. |
400 | InvalidLoadBalancerId.RegionMismatch | The load balancer "%s" and the specified scaling group are not in the same Region. | The CLB instance and the scaling group do not reside in the same region. |
400 | IncorrectLoadBalancerStatus | The current status of the load balancer "%s" does not support this action. | The operation is not supported when the CLB instance is in the current state. |
400 | IncorrectLoadBalancerHealthCheck | The current health check type of the load balancer "%s" does not support this action. | The health check feature is not enabled for the CLB instance. |
400 | InvalidLoadBalancerId.VPCMismatch | The specified virtual switch and the instance in the load balancer "%s" are not in the same VPC. | The CLB instance and the scaling group do not reside in the same VPC. |
400 | InvalidVServerGroupId.ForLoadBalancer | Invalid VServerGroupId For LoadBalancer "%s". | The vServer group that is specified by VServerGroupId does not belong to the specified CLB instance. |
400 | QuotaExceeded.VServerGroup | VServerGroup quota exceeded in the specified scaling group. | The maximum number of vServer groups that can be attached to the scaling group has been reached. |