detachInstances method
Removes one or more instances from the specified Auto Scaling group.
After the instances are detached, you can manage them independent of the Auto Scaling group.
If you do not specify the option to decrement the desired capacity, Amazon EC2 Auto Scaling launches instances to replace the ones that are detached.
If there is a Classic Load Balancer attached to the Auto Scaling group, the instances are deregistered from the load balancer. If there are target groups attached to the Auto Scaling group, the instances are deregistered from the target groups.
For more information, see Detach or attach instances in the Amazon EC2 Auto Scaling User Guide.
May throw ResourceContentionFault.
Parameter autoScalingGroupName :
The name of the Auto Scaling group.
Parameter shouldDecrementDesiredCapacity :
Indicates whether the Auto Scaling group decrements the desired capacity
value by the number of instances detached.
Parameter instanceIds :
The IDs of the instances. You can specify up to 20 instances.
Implementation
Future<DetachInstancesAnswer> detachInstances({
required String autoScalingGroupName,
required bool shouldDecrementDesiredCapacity,
List<String>? instanceIds,
}) async {
final $request = <String, String>{
'AutoScalingGroupName': autoScalingGroupName,
'ShouldDecrementDesiredCapacity':
shouldDecrementDesiredCapacity.toString(),
if (instanceIds != null)
if (instanceIds.isEmpty)
'InstanceIds': ''
else
for (var i1 = 0; i1 < instanceIds.length; i1++)
'InstanceIds.member.${i1 + 1}': instanceIds[i1],
};
final $result = await _protocol.send(
$request,
action: 'DetachInstances',
version: '2011-01-01',
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
resultWrapper: 'DetachInstancesResult',
);
return DetachInstancesAnswer.fromXml($result);
}