scale in protection setting in auto scaling group is ignored

0

We have

  • an ecs cluster
  • with a managed auto scaling group (aws_ecs_capacity_provider)
  • and a aws_launch_template to create EC2 instances

we manually turned off the scale in protection in the advanced settiongs of the ASG. But every new EC2 machine that is created by the ASG is again scale-in-protected. Problem: we want to use scheduled actions to automatically set the desired capacity periodically up and down. And the reduction is not working when we do not manually switch off the scale-in-protection every time an the EC2 instances.

This seems like a bug in AWS, because the property 'protect_from_scale_in' on the ASG has no effect! Please help!

Kind regards,

1 Answer
0

ok. while formulating this question i stumbled upon a setting in our aws_ecs_capacity_provider: we have set managed_termination_protection to "ENABLED". According to the AWS docs, this only should be possible in case the protect_from_scale_in is enabled too. But we do not get an error (neither via AWS console nor via terraform apply), nor is the change of the protect_from_scale_in to false automatically disabling the managed_termination_protection. (!)

I have set the managed_termination_protection to "DISABLED" manually via AWS console and hope tomorrow our new EC2 instances will be launched with scale-in-protecion set to false.

answered 2 years ago
  • The requirement is one way. The protect_from_scale_in setting has to be enabled on the ASG for managed_termination_protection to be enabled in ECS; but AutoScaling isn't aware of the ECS capacity provider, and so it lets you turn the setting off on the ASG at any time.

    With managed_termination_protection disabled, make sure you have a lifecycle hook on the ASG set to tell ECS to drain the running tasks before instance termination (or some other method to do the same thing). Example: https://aws.amazon.com/blogs/compute/how-to-automate-container-instance-draining-in-amazon-ecs/

  • Thank you Shahad_C. Just wanted to mention, that managed_termination_protection was the problem indeed. After disabling it, it works fine :)

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions