setInstanceProtection method

Future<void> setInstanceProtection({
  1. required String autoScalingGroupName,
  2. required List<String> instanceIds,
  3. required bool protectedFromScaleIn,
})

Updates the instance protection settings of the specified instances.

For more information about preventing instances that are part of an Auto Scaling group from terminating on scale in, see 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 {
  ArgumentError.checkNotNull(autoScalingGroupName, 'autoScalingGroupName');
  _s.validateStringLength(
    'autoScalingGroupName',
    autoScalingGroupName,
    1,
    255,
    isRequired: true,
  );
  ArgumentError.checkNotNull(instanceIds, 'instanceIds');
  ArgumentError.checkNotNull(protectedFromScaleIn, 'protectedFromScaleIn');
  final $request = <String, dynamic>{};
  $request['AutoScalingGroupName'] = autoScalingGroupName;
  $request['InstanceIds'] = instanceIds;
  $request['ProtectedFromScaleIn'] = protectedFromScaleIn;
  await _protocol.send(
    $request,
    action: 'SetInstanceProtection',
    version: '2011-01-01',
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    shape: shapes['SetInstanceProtectionQuery'],
    shapes: shapes,
    resultWrapper: 'SetInstanceProtectionResult',
  );
}