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,

已提問 2 年前檢視次數 1012 次
1 個回答
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.

已回答 2 年前
  • 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 :)

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南