0 votes
1 view
in AWS by (5.8k points)

I would like to prevent EC2 instance termination by Auto Scaling feature if that instance is in the middle of some sort of processing.

Background:

Suppose I have an Auto Scaling group that currently has 5 instances running. I create an alarm on average CPU usage... Suppose 4 of the instances are idle and one is doing some heavy processing... The average CPU load will trigger the alarm and as a result the scale-down policy will execute.

How do I get Auto Scaling to terminate one of the idle instances and not the one that is in the middle of the processing?

1 Answer

+1 vote
by (18.5k points)
selected by
 
Best answer

AWS provides an instance protection feature to control whether the autoscaling can terminate an instance when scaling in or not. 

According to the official documentation:

You can enable the instance protection setting on an autoscaling group or on a single autoscaling instance. if you have enabled it on an autoscaling group and a new instance gets launched then it will inherit the protection setting of the autoscaling group.

You can enable this feature using your AWS console as well as AMW CLI.

Refer to the following link for more information:

https://docs.aws.amazon.com/AutoScaling/latest/DeveloperGuide/AutoScalingBehavior.InstanceTermination.html#instance-protection

...