Issue
I have my API configured on an EC2 instance (AWS) and have reserved an Elastic IP to be associated with my instance. I also have an ELB configured that points to my public IP (reserved) and with the target group pointing to my EC2 instance.
Every 24 hours (sometimes at a gap of 3-6 hours) my instance gets terminated automatically and a new instance gets created by AWS. While this is fine, it unlinks my Elastic IP (Even after reserving) and removed the new instance from my ELB target groups.
I get a 503 Service Temporarily Unavailable
error on my API since the public IP becomes invalid. Everytime this happens (roughly every 24 hours) I need to re-associate the IP with my instance (Elastic IP) and register a new target in my Load Balancer.
How do I go about fixing this?
Solution
This was a while back, and what seems to have been working well for me is adding the applicable Target Group under the Target Group section under the Auto Scaling Groups.
So go to EC2 Console, then at the very bottom of the left menu (currently for me anyway), there's the Auto Scaling Groups. Click on the auto-scaling group from the list, and on the Details tab, click Edit, and then add the applicable Target Group.
This then seems to keep them in sync even as the instances change.
This text is from https://serverfault.com/questions/1000783/application-load-balancer-with-aws-elastic-beanstalk-target-group and it worked for me.
Answered By - djiki Answer Checked By - Terry (WPSolving Volunteer)