Why do we need a NAT Gateway?
In the last session, we created a custom VPC with a private subnet to lock down backend databases and application servers. Nobody on the internet could reach them.
Network isolation is great for security, but it creates a real problem:
How does your private EC2 server download security updates ( apt update or dnf update )?
How does it download packages or call external APIs like Stripe, Twilio, or GitHub?
If you attach an Internet Gateway directly to the private subnet, it is no longer private—anyone on the internet can scan your ports.
A NAT Gateway solves this problem. It allows private servers to reach out to the internet, while completely blocking the internet from starting connections back into your private servers.
1.…