2

i have an aws asg -> config : min=2 , max=2 , desired capacity =2 I did this

  1. set an instance with scale-in protection.

  2. suspended process of launch and ReplaceUnhealthy to avoid creation of new instancetermination of stopped instance.

     aws autoscaling set-instance-protection --instance-ids i-xxxxxxxxxxxx --auto-scaling-group-name xxxxxxxxxxxxxxxx --protected-from-scale-in
    
     aws autoscaling suspend-processes --auto-scaling-group-name xxxxxxxxxxxxxxxxxxx --scaling-processes Launch ReplaceUnhealthy
    
    aws ec2 stop-instances --instance-ids i-xxxxxxxxxxxxxx
    

all good so far. now to revert back the changes i did

aws ec2 start-instances --instance-ids xxxxxxxxxxxxxxxxxxx

instance is started again

 aws autoscaling resume-processes --auto-scaling-group-name xxxxxxxxxxxxxxxxxxxxxxxxxx --scaling-processes Launch ReplaceUnhealthy
  • Now after this command asg launches a new instance which makes it 3 and then delete the old instance which should not happen, new instance should not be launched, and just old instance should be started again.
  • so that means scale-in protection is not working.

why scale-in doesn't work, what condition it needs to fulfill to protect that instance which was started again to prevent getting terminated and prevent the new instance from being launched.

Jatin Mehrotra
  • 9,286
  • 4
  • 28
  • 67

1 Answers1

1

I think this can be explained by how ReplaceUnhealthy works:

As soon as you resume the ReplaceUnhealthly process, Amazon EC2 Auto Scaling replaces instances that were marked unhealthy while this process was suspended.

So even though you suspended the ReplaceUnhealthy, during this time your instance got unhealthy due to stopping it. When the process resumed, ASG "remembered" that the instance was faulty at one point and it replaces it when you resume the process.

Marcin
  • 215,873
  • 14
  • 235
  • 294