setInstanceProtection method
Updates the instance protection settings of the specified instances. This operation cannot be called on instances in a warm pool.
For more information, see Use instance scale-in protection in the Amazon EC2 Auto Scaling User Guide.
If you exceed your maximum limit of instance IDs, which is 50 per Auto Scaling group, the call fails.
May throw LimitExceededFault.
May throw ResourceContentionFault.
Parameter autoScalingGroupName :
The name of the Auto Scaling group.
Parameter instanceIds :
One or more instance IDs. You can specify up to 50 instances.
Parameter protectedFromScaleIn :
Indicates whether the instance is protected from termination by Amazon EC2
Auto Scaling when scaling in.
Implementation
Future<void> setInstanceProtection({
required String autoScalingGroupName,
required List<String> instanceIds,
required bool protectedFromScaleIn,
}) async {
final $request = <String, String>{
'AutoScalingGroupName': autoScalingGroupName,
if (instanceIds.isEmpty)
'InstanceIds': ''
else
for (var i1 = 0; i1 < instanceIds.length; i1++)
'InstanceIds.member.${i1 + 1}': instanceIds[i1],
'ProtectedFromScaleIn': protectedFromScaleIn.toString(),
};
await _protocol.send(
$request,
action: 'SetInstanceProtection',
version: '2011-01-01',
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
resultWrapper: 'SetInstanceProtectionResult',
);
}