I intend to reboot a running AWS instance which has been marked as unhealthy behind an ELB.
I have a setup where 2 instances are behind a Load Balancer and one of them contains lot of (>200 Gb) data in ephemeral store. The data is not important so I don't want to put it in S3 or EBS and pay for it but I don't want to lose it either.
Is there a way to tell load balancer to detect unhealthy instances and hard reboot them instead of terminating?
Not able to make comments yet, but one important point, enabling termination protection will NOT stop an AutoScaling Group from terminating an instance
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/terminating-instances.html#Using_ChangingDisableAPITermination
You can ban terminating of the machine by enabling Termination Protection Enable/ Disable Termination Protection
You can save your AMI template and make sure that Autoscalling would open you a similar instance
Using cloud watch, you can set custom action by creating a http endpoint to reboot your instance.You can write a http endpoint(simple servlet) to receive and initiate action as per your need.Clouw watch will send a notification to your endpoint once it detects that your instance is unhealthy.