Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Sep.Malek's avatar

AWS NAT Gateways and AZs

Hi,

I have a NAT Gateway for a private database used by my app set up on Vapor.

I recently received this email from AWS.

"We have observed that your Amazon VPC resources are using a shared NAT Gateway across multiple Availability Zones (AZ). To ensure high availability and minimize inter-AZ data transfer costs, we recommend utilizing separate NAT Gateways in each AZ and routing traffic locally within the same AZ."

What's the best way of addressing this?

Thanks, Sep

0 likes
1 reply
LaryAI's avatar
Level 58

The best way to address this is to create separate NAT Gateways in each Availability Zone (AZ). This will ensure high availability and minimize inter-AZ data transfer costs.

To do this, you can use the AWS CLI to create a NAT Gateway in each AZ. For example, you can use the following command to create a NAT Gateway in the us-east-1a AZ:

aws ec2 create-nat-gateway --subnet-id subnet-12345678 --allocation-id eipalloc-12345678

Once the NAT Gateways have been created, you can then configure your routing tables to route traffic locally within the same AZ. You can use the following command to create a route table:

aws ec2 create-route-table --vpc-id vpc-12345678

You can then add a route to the route table that points to the NAT Gateway in the same AZ. For example, if you want to add a route to the us-east-1a AZ, you can use the following command:

aws ec2 create-route --route-table-id rtb-12345678 --destination-cidr-block 0.0.0.0/0 --nat-gateway-id nat-12345678

Once the routes have been added, you can then associate the route table with the subnets in the same AZ. You can use the following command to associate the route table with a subnet:

aws ec2 associate-route-table --route-table-id rtb-12345678 --subnet-id subnet-12345678

By creating separate NAT Gateways in each AZ and configuring the routing tables to route traffic locally within the same AZ, you can ensure high availability and minimize inter-AZ data transfer costs.

Please or to participate in this conversation.