scale in protection setting in auto scaling group is ignored
- 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!
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.
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 :)
Autoscaling instance are protected from scale-inasked a month ago
Autoscaling with pythonasked 2 months ago
Spot Instance interruption while CodeDeploy is running a deployment to an Auto Scaling groupAccepted AnswerEXPERTasked 2 years ago
AWS batch does not scale down EC2 instancesasked 4 months ago
force auto scaling group to scale in by terminating k8s pods ungracefullyasked 9 months ago
How are EBS volumes in an unhealthy instance handled when a new instance is created by Auto Scaling?Accepted Answerasked 2 years ago
scale in protection setting in auto scaling group is ignoredasked a month ago
Why is Auto Scaling Group not taking Security Group from Launch Template?Accepted Answerasked a month ago
Orphaned nodegroup keeps creating EC2 instanceasked a year ago
A new EC2 instance is created after termination of the only instanceAccepted Answerasked 2 years ago