NAT Gateway Deployment
What you'll learn: How to actually deploy a NAT Gateway in a public subnet and route private subnet traffic through it.
Understanding the Deployment Process
Deploying a NAT Gateway involves two key steps: placing the gateway itself in a public subnet (where it can reach the internet), and configuring your private subnet's route table to send outbound traffic through it.
Think of it like installing a mail room in your office building. The mail room (NAT Gateway) needs to be on the ground floor with street access (public subnet), while employees on upper floors (private subnet) send their mail through it without needing their own street-level door.
Step 1: Deploy NAT Gateway in Public Subnet
The NAT Gateway must live in a public subnet because it needs direct internet access via an Internet Gateway. During deployment, you'll:
- Select a public subnet in your availability zone
- Allocate or assign an Elastic IP address (the NAT Gateway's public-facing IP)
- Create the NAT Gateway resource
The Elastic IP becomes the "return address" for all outbound traffic from your private instances.
Step 2: Configure Private Subnet Routing
Next, update the route table associated with your private subnet:
- Add a route: destination
0.0.0.0/0(all internet traffic) - Target: your NAT Gateway ID
This tells instances in the private subnet: "For any internet-bound traffic, send it to the NAT Gateway." The NAT Gateway then forwards it using its Elastic IP, handles the response, and returns data to the original private instance.
Key Takeaway: Deploy your NAT Gateway in a public subnet with an Elastic IP, then point your private subnet's route table to it for outbound internet access while keeping instances private.