Building a VPC without the wizard finally explained private subnets to me
I'd been using the VPC wizard for months without really understanding it. Doing it by hand showed me that a subnet is private or public only because of its route table.
I used the "VPC and more" wizard for months. It works great, and I could not have explained to you what it created. That became a problem when a TA in my networking class asked me why my instance couldn't reach the internet and all I could say was "the wizard made it."
So one evening I deleted everything and built a VPC in the console by hand, one resource at a time, writing down what each step changed.
The biggest surprise was that there is no "private" setting on a subnet. I kept looking for it. A subnet is public or private purely because of the route table it's associated with. If that route table sends
0.0.0.0/0 to an internet gateway, the subnet is public. If it doesn't, it's private. That's it. It sounds obvious written down, but it made a whole chapter of my study notes suddenly make sense.I also made every beginner mistake along the way:
- I created the internet gateway and tried to add the route before attaching it to the VPC. The console refused with an error saying the route table and the gateway belonged to different networks, which made no sense to me until I realized creating a gateway and attaching it are two separate steps.
- I created a new route table for the public subnet and never associated it with the subnet, so the subnet was still using the main route table, which had no internet route.
- After fixing both, my instance still wasn't reachable, because it didn't have a public IP. My hand-made subnet didn't auto-assign one.
Now when something can't reach the internet I check the same three things in that order: which route table the subnet is really using, whether the internet gateway is attached, and whether the instance has a public address. It's a boring checklist. I only remember it because I broke all three.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article