0

When attaching an ASG to a Target Group with "Connection Draining" enabled, I would expect that instances that are being terminated by the ASG (Due to scale down for example) will first move to the "draining" phase before actually being terminated, but this is not the case. Instead what happens is that the instance is being terminated immediately without being drained at all.

If I manually remove an ASG instance from the Target Group, it does move to the "draining" phase, and afterwards I can safely terminate it. (Again, manually).

I'm pretty sure this is not the way its intended to work. Any advice?

shaharmor
  • 317
  • 4
  • 15

1 Answers1

0

So I figured it out.

The way to do it is create an ASG lifecycle hook that listens to the autoscaling:EC2_INSTANCE_TERMINATING action and waits the given amount of time you want for the instance to have before being killed. The results for the action timeout should be CONTINUE so that it will actually delete the instance once the timeout has passed.

This way you can clean up leftovers, close connections, etc.

shaharmor
  • 317
  • 4
  • 15