Fixing AWS VPC Connectivity
When I took on the Networking Quest in AWS , I ran into a classic issue that many cloud engineers face — EC2 instances with no internet access and broken app connectivity.
Here’s a breakdown of what I did and what I learned along the way.
The Problem
After deploying web and database servers to AWS, the following issues were noticed:
- The EC2 instances couldn’t reach the internet.
- The web server couldn’t talk to the database.
Turns out — VPC misconfiguration was the root cause.
Architecture Diagram
The Fix – Step by Step
1. Set up Public and Private Subnets
10.10.0.0/24
for the public subnet (web server)10.10.2.0/24
for the private subnet (DB server)
2. Attach an Internet Gateway
- Created and attached an IGW to the VPC
- Updated the public subnet’s route table to allow
0.0.0.0/0
via IGW
3. Assign Public IP to Web Server
- Made the web server reachable via HTTP from the internet
4. Security Groups
- Web server: Open port 80 for all (
0.0.0.0/0
) - DB server: Open port 3306 only to the web server’s private IP
5. Why the DB Server Couldn’t Connect?
- It was in a private subnet with no NAT or IGW — by design!
- Only internal connections from the web server were allowed
Takeaways
- Always verify route tables and subnet associations.
- Assign a public IP only when necessary.
- Use security groups for precise, layered control.
Bonus Tip
Create a reusable Terraform module to automate this setup — makes you look sharp in interviews!
Thanks for reading!
Feel free to check out the GitHub repo here.