AWS VPC Explained: A Beginner’s Guide to Building a Secure Cloud Network
Learn the fundamentals of Amazon VPC, including subnets, route tables, Internet Gateway, NAT Gateway, Security Groups, and Network ACLs, with a simple real-world architecture.
AWS VPC Explained: A Beginner’s Guide to Building a Secure Cloud Network
When I started learning AWS, one of the first networking services I came across was Amazon VPC (Virtual Private Cloud). Understanding VPC is important because most AWS workloads require a properly designed network.
In this article, I’ll explain the basic components of an AWS VPC and how they work together to create a secure and scalable cloud network.
What is Amazon VPC?
Amazon VPC allows us to create a logically isolated virtual network inside AWS.
Within a VPC, we can define:
- IP address ranges
- Subnets
- Route tables
- Internet connectivity
- Network security rules
For example, we can create a VPC with the CIDR:
10.0.0.0/16 This gives us a private IP address range that we can divide into multiple subnets.
Public and Private Subnets
A VPC can contain different types of subnets.
Public Subnet
A public subnet is generally used for resources that need direct internet connectivity, such as:
- Web servers
- Load balancers
- Bastion hosts
A subnet becomes public when its route table has a route to an Internet Gateway.
Private Subnet
Private subnets are commonly used for resources that should not be directly accessible from the internet.
Examples include:
- Application servers
- Databases
- Internal services
This separation improves security by keeping sensitive resources away from direct internet access.
Internet Gateway
An Internet Gateway (IGW) provides communication between resources in a VPC and the public internet.
For example:
EC2 → Internet Gateway → Internet For an EC2 instance in a public subnet to communicate directly with the internet, it generally needs:
- A route to the Internet Gateway
- A public IPv4 address or another suitable public connectivity mechanism
- Appropriate security rules
NAT Gateway
A NAT Gateway is commonly used when resources in a private subnet need to access the internet for outbound connections.
For example, a private EC2 instance might need to download software updates.
The traffic can follow:
Private EC2 → NAT Gateway → Internet Gateway → Internet The important point is that the private instance doesn't need to be directly reachable from the internet.
Route Tables
Route tables determine where network traffic should go.
For example, a public subnet might have:
0.0.0.0/0 → Internet Gateway A private subnet might have:
0.0.0.0/0 → NAT Gateway This allows AWS to determine the next destination for traffic leaving the subnet.
Security Groups
Security Groups act as a stateful virtual firewall for AWS resources such as EC2 instances.
For example, we can allow:
- HTTP — port 80
- HTTPS — port 443
- SSH — port 22 from a trusted source
A good security practice is to avoid opening ports to
0.0.0.0/0 unless there is a specific reason to do so.For example, instead of allowing SSH from anywhere, we can restrict it to a trusted IP address or use a more secure access method.
Network ACLs
Network ACLs (NACLs) provide another layer of network traffic control at the subnet level.
Unlike Security Groups, NACLs are stateless, meaning inbound and outbound traffic rules are evaluated separately.
They can be useful as an additional security layer for controlling traffic entering or leaving a subnet.
Simple VPC Architecture
A basic production-style architecture could look like this:
Internet | Internet Gateway | +--------+--------+ | | Public Subnet Public Subnet | | Load Balancer Bastion Host | ---------------- | | Private Subnet Private Subnet | | Application Database Server Server | NAT Gateway | InternetThe exact architecture depends on the application's requirements, but the main idea is to separate internet-facing resources from internal resources.
Best Practices
While designing a VPC, some useful practices are:
- Plan the CIDR range before creating the network.
- Use multiple Availability Zones for high availability.
- Keep databases in private subnets.
- Avoid unnecessary public IP addresses.
- Follow the principle of least privilege for Security Groups.
- Restrict administrative access such as SSH.
- Use separate subnets for different application tiers.
- Monitor and review network traffic regularly.
Conclusion
Amazon VPC is one of the most important AWS services to understand when learning Cloud or DevOps.
The key components I focused on are:
VPC → Subnets → Route Tables → Internet Gateway → NAT Gateway → Security Groups → Network ACLs
Once these concepts are clear, understanding AWS services such as EC2, Load Balancers, RDS, and EKS becomes much easier.
I’m continuing to learn AWS and DevOps by building practical projects and experimenting with different cloud architectures. My goal is to understand not only how AWS services work individually, but also how they work together to build secure and scalable applications.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article