attachInstances method

Future<void> attachInstances({
  1. required String autoScalingGroupName,
  2. List<String>? instanceIds,
})

Attaches one or more EC2 instances to the specified Auto Scaling group.

When you attach instances, Amazon EC2 Auto Scaling increases the desired capacity of the group by the number of instances being attached. If the number of instances being attached plus the desired capacity of the group exceeds the maximum size of the group, the operation fails.

If there is a Classic Load Balancer attached to your Auto Scaling group, the instances are also registered with the load balancer. If there are target groups attached to your Auto Scaling group, the instances are also registered with the target groups.

For more information, see Attach EC2 instances to your Auto Scaling group in the Amazon EC2 Auto Scaling User Guide.

May throw ResourceContentionFault. May throw ServiceLinkedRoleFailure.

Parameter autoScalingGroupName : The name of the Auto Scaling group.

Parameter instanceIds : The IDs of the instances. You can specify up to 20 instances.

Implementation

Future<void> attachInstances({
  required String autoScalingGroupName,
  List<String>? instanceIds,
}) async {
  ArgumentError.checkNotNull(autoScalingGroupName, 'autoScalingGroupName');
  _s.validateStringLength(
    'autoScalingGroupName',
    autoScalingGroupName,
    1,
    255,
    isRequired: true,
  );
  final $request = <String, dynamic>{};
  $request['AutoScalingGroupName'] = autoScalingGroupName;
  instanceIds?.also((arg) => $request['InstanceIds'] = arg);
  await _protocol.send(
    $request,
    action: 'AttachInstances',
    version: '2011-01-01',
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    shape: shapes['AttachInstancesQuery'],
    shapes: shapes,
  );
}