AutoScaling.Client.
set_instance_protection
(**kwargs)¶Updates the instance protection settings of the specified instances. This operation cannot be called on instances in a warm pool.
For more information about preventing instances that are part of an Auto Scaling group from terminating on scale in, see Using 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.
See also: AWS API Documentation
Request Syntax
response = client.set_instance_protection(
InstanceIds=[
'string',
],
AutoScalingGroupName='string',
ProtectedFromScaleIn=True|False
)
[REQUIRED]
One or more instance IDs. You can specify up to 50 instances.
[REQUIRED]
The name of the Auto Scaling group.
[REQUIRED]
Indicates whether the instance is protected from termination by Amazon EC2 Auto Scaling when scaling in.
dict
Response Syntax
{}
Response Structure
Exceptions
AutoScaling.Client.exceptions.LimitExceededFault
AutoScaling.Client.exceptions.ResourceContentionFault
Examples
This example enables instance protection for the specified instance.
response = client.set_instance_protection(
AutoScalingGroupName='my-auto-scaling-group',
InstanceIds=[
'i-93633f9b',
],
ProtectedFromScaleIn=True,
)
print(response)
Expected Output:
{
'ResponseMetadata': {
'...': '...',
},
}
This example disables instance protection for the specified instance.
response = client.set_instance_protection(
AutoScalingGroupName='my-auto-scaling-group',
InstanceIds=[
'i-93633f9b',
],
ProtectedFromScaleIn=False,
)
print(response)
Expected Output:
{
'ResponseMetadata': {
'...': '...',
},
}