0
votes

I have instances behind the ALB and health check is set to ELB. Once ELB health check fails for a particular instance, the Auto-Scaling Group (ASG) is terminating unhealthy instance and launching the new instance, instead of terminating the instance I want detach from the ASG for my analysis and launch new instance.

1

1 Answers

1
votes

Theres no out of the box solution which would allow a new instance to replace this one. You could do it with some automation though.

Firsty, you can use lifecycle hooks to actually make use of these events for a specific instance. By creating one for termination events you could trigger a SNS notification.

This SNS notification could then trigger a Lambda function providing the instance metadata. From here the Lambda could remove the instance from the ASG, plus notify you if you want it.

Once the instance is removed from the autoscaling group it should scale up to desired numbers again, finally make sure to notify the lifecycle hook that its complete.

You may also need to add termination protection just in case too (programatically) but not 100% sure without testing.

Hope this helps