Issue
I have my frontend & backend application in separate ec2 behind a single application load balancer with different target groups. I need to have a static IP address that can be whitelisted with a 3rd party notification system.
I need a way to provide a statis IP address and allows access to my instances in a case where my ec2 are autoscaled or recreated from a launch template.
Can i get a static IP address to provide to a vendor and there will still be access to my application even when my server autoscales or is replaced,
Solution
It sounds like you need an outgoing static IP address, so your EC2 servers can send traffic to an external resource always using that IP address. To do this you have to take the following steps:
Add a NAT Gateway to one of your VPC's public subnets. A public subnet is a subnet with a route to an Internet Gateway in its route table. All of your VPC's subnets are probably public subnets right now.
Assign an Elastic IP to the NAT Gateway when you create it.
Create some private subnets in your VPC. Private subnets are subnets that have a route to the NAT Gateway, instead of the Internet Gateway, in their route table.
Modify your auto-scaling group to deploy your EC2 instances in the private subnets, instead of the public subnets.
Once you take the above steps, any outgoing network request originating from your EC2 servers will go through the NAT Gateway and appear to external resources as coming from the Elastic IP address.
Answered By - Mark B Answer Checked By - Timothy Miller (WPSolving Admin)