Nat – AWS load balancer, multiple instances – NAT

amazon ec2amazon-web-servicesload balancingnat;

I got my app hosted on AWS, I use load balancer for it so I have to EC2 instances up. I need now to connect to some external service, but this service allows to connect from single IP.

I was thinking about setting up NAT gateway for my apps, but I don't know if I can setup one for all availability zones (I got my app configured in 3 AZ) of my app.

Do you have any idea how to make outbound requests from all my EC2 instances across all AZ/subnets to have single IP address?

Best Answer

If your app is deployed to a single VPC using the 3 Availability Zones then all you need to do is create a NAT Gateway on one of you public VNETs and then create a new Route table and add a route to send 0.0.0.0/0 traffic through the new NAT Gateway. Finally associate the subnets that contain your app to the new route table.

A single NAT gateway can be used by any subnets in the same VPC regardless of the AZs that you have deployed the subnets to. When you create your NAT Gateway it will be given a single Elastic IP Address to use that will represent all the traffic being sent through the NAT Gateway.