14

I am making an AWS ECS cluster using EC2 and trying to use capacity providers. I don't really understand why do I need to enable instance scale-in protection inside my AWS Auto Scaling group.

Isn't the point of Auto Scaling the termination of needless EC2 instances?

BinaryButterfly
  • 18,137
  • 13
  • 50
  • 91
s3nti3ntB
  • 391
  • 4
  • 11

1 Answers1

20

why do I need to enable instance scale-in protection

This is only needed when you chose to use managed scaling:

When managed scaling is enabled, Amazon ECS manages the scale-in and scale-out actions of the Auto Scaling group used when creating the capacity provider. On your behalf, Amazon ECS creates an AWS Auto Scaling scaling plan with a target tracking scaling policy based on the target capacity value you specify.

The managed scaling ensures that ECS controlled when instances are removed. By doing this it protects any instances that have some tasks running on it from being terminated:

When managed termination protection is enabled, Amazon ECS prevents Amazon EC2 instances that contain tasks and that are in an Auto Scaling group from being terminated during a scale-in action.

The entire idea is that you enable instance scale-in protection on your ASG so that ECS has control over which instances to terminate based on tasks they run. Without this, your ASG could terminate instances based on other criteria, not nervelessly related to "needless EC2 instances". For example, ASG can choose to terminate instances based due to AZRebalance process. This could lead to ASG terminating instances with running tasks, which may not be what you want.

BinaryButterfly
  • 18,137
  • 13
  • 50
  • 91
Marcin
  • 215,873
  • 14
  • 235
  • 294
  • 1
    Thank you for your answer! So that basically means that by enabling scale-in protection, we restrict AWS to terminate instances only by a criteria based on tasks they run, and we do not enable AWS to take into account other criteria except that one? – s3nti3ntB Jul 09 '20 at 23:51
  • @s3nti3ntB No problem. Its not fully clear from docs if ECS will have absolute control, but ECS will make most, if not all, decisions about the scaling procedures based on tasks. – Marcin Jul 09 '20 at 23:54