attachLoadBalancerTargetGroups method

Future<void> attachLoadBalancerTargetGroups({
  1. required String autoScalingGroupName,
  2. required List<String> targetGroupARNs,
})

Attaches one or more target groups to the specified Auto Scaling group.

This operation is used with the following load balancer types:

  • Application Load Balancer - Operates at the application layer (layer 7) and supports HTTP and HTTPS.
  • Network Load Balancer - Operates at the transport layer (layer 4) and supports TCP, TLS, and UDP.
  • Gateway Load Balancer - Operates at the network layer (layer 3).
To describe the target groups for an Auto Scaling group, call the DescribeLoadBalancerTargetGroups API. To detach the target group from the Auto Scaling group, call the DetachLoadBalancerTargetGroups 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 targetGroupARNs : The Amazon Resource Names (ARN) of the target groups. You can specify up to 10 target groups. To get the ARN of a target group, use the Elastic Load Balancing DescribeTargetGroups API operation.

Implementation

Future<void> attachLoadBalancerTargetGroups({
  required String autoScalingGroupName,
  required List<String> targetGroupARNs,
}) async {
  ArgumentError.checkNotNull(autoScalingGroupName, 'autoScalingGroupName');
  _s.validateStringLength(
    'autoScalingGroupName',
    autoScalingGroupName,
    1,
    255,
    isRequired: true,
  );
  ArgumentError.checkNotNull(targetGroupARNs, 'targetGroupARNs');
  final $request = <String, dynamic>{};
  $request['AutoScalingGroupName'] = autoScalingGroupName;
  $request['TargetGroupARNs'] = targetGroupARNs;
  await _protocol.send(
    $request,
    action: 'AttachLoadBalancerTargetGroups',
    version: '2011-01-01',
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    shape: shapes['AttachLoadBalancerTargetGroupsType'],
    shapes: shapes,
    resultWrapper: 'AttachLoadBalancerTargetGroupsResult',
  );
}