attachLoadBalancers method
To describe the load balancers for an Auto Scaling group, call the DescribeLoadBalancers API. To detach a load balancer from the Auto Scaling group, call the DetachLoadBalancers API.
This operation is additive and does not detach existing Classic Load Balancers or target groups from the Auto Scaling group.
For more information, see Use Elastic Load Balancing to distribute traffic across the instances in your Auto Scaling group in the Amazon EC2 Auto Scaling User Guide.
May throw InstanceRefreshInProgressFault.
May throw ResourceContentionFault.
May throw ServiceLinkedRoleFailure.
Parameter autoScalingGroupName :
The name of the Auto Scaling group.
Parameter loadBalancerNames :
The names of the load balancers. You can specify up to 10 load balancers.
Implementation
Future<void> attachLoadBalancers({
required String autoScalingGroupName,
required List<String> loadBalancerNames,
}) async {
final $request = <String, String>{
'AutoScalingGroupName': autoScalingGroupName,
if (loadBalancerNames.isEmpty)
'LoadBalancerNames': ''
else
for (var i1 = 0; i1 < loadBalancerNames.length; i1++)
'LoadBalancerNames.member.${i1 + 1}': loadBalancerNames[i1],
};
await _protocol.send(
$request,
action: 'AttachLoadBalancers',
version: '2011-01-01',
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
resultWrapper: 'AttachLoadBalancersResult',
);
}