attachLoadBalancers method

Future<void> attachLoadBalancers({
  1. required String autoScalingGroupName,
  2. required List<String> loadBalancerNames,
})
Attaches one or more Classic Load Balancers to the specified Auto Scaling group. Amazon EC2 Auto Scaling registers the running instances with these Classic Load Balancers.

To describe the load balancers for an Auto Scaling group, call the DescribeLoadBalancers API. To detach the load balancer from the Auto Scaling group, call the DetachLoadBalancers API.

For more information, see Elastic Load Balancing and Amazon EC2 Auto Scaling in the Amazon EC2 Auto Scaling User Guide.

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 {
  ArgumentError.checkNotNull(autoScalingGroupName, 'autoScalingGroupName');
  _s.validateStringLength(
    'autoScalingGroupName',
    autoScalingGroupName,
    1,
    255,
    isRequired: true,
  );
  ArgumentError.checkNotNull(loadBalancerNames, 'loadBalancerNames');
  final $request = <String, dynamic>{};
  $request['AutoScalingGroupName'] = autoScalingGroupName;
  $request['LoadBalancerNames'] = loadBalancerNames;
  await _protocol.send(
    $request,
    action: 'AttachLoadBalancers',
    version: '2011-01-01',
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    shape: shapes['AttachLoadBalancersType'],
    shapes: shapes,
    resultWrapper: 'AttachLoadBalancersResult',
  );
}