
Amazon VPC Explained: Build Your Own Isolated Network in AWS from Scratch
Understand Amazon Virtual Private Cloud from the ground up. Explore VPC architecture, IP address allocation, subnets, Availability Zones, routing, internet connectivity, and network security through practical examples and real-world cloud architectures.
Amazon VPC Explained: Build Your Own Isolated Network in AWS from Scratch
Introduction
When you deploy an application on AWS, where do its servers live? How do they communicate with each other? How do you decide which resources are accessible from the internet and which must remain private?
These questions introduce one of the most fundamental services in AWS: Amazon Virtual Private Cloud (Amazon VPC).
A VPC allows you to create a logically isolated virtual network inside AWS. You decide its IP address range, divide it into subnets, configure routing, and control communication between resources.
Think of it as building your own network infrastructure in the cloud.
In this article, we will understand VPC architecture, its components, how they interact, and how to build a practical network for an application.
1. What is Amazon VPC?
Amazon VPC is a logically isolated virtual network dedicated to your AWS account.
It allows you to launch resources such as EC2 instances and configure their networking according to your requirements.
A VPC provides control over:
- IPv4 and IPv6 address ranges.
- Subnet creation.
- Network routing.
- Internet connectivity.
- Private connectivity.
- Security and traffic filtering.
- Connectivity with other networks.
For example, imagine developing an e-commerce application containing a frontend, backend, and database.
You can create a VPC and place these resources in separate subnets according to their responsibilities.
The frontend can receive public requests, the backend can communicate privately, and the database can remain inaccessible directly from the internet.
2. Understanding VPC Architecture
A VPC does not automatically contain your application servers.
Instead, it provides the network environment in which you deploy and connect AWS resources.
A simplified architecture looks like this:
AWS REGION | +-------+-------+ | | v v Availability Availability Zone A Zone B | | +------+-----+ +-----+------+ | | | | v v v v Public Private Public Private Subnet Subnet Subnet Subnet | | | | v v v v Web EC2 App EC2 Web EC2 App EC2 \ | / \ | / +-----+-----+ | VPCThe VPC provides the overall network boundary, while subnets organize resources within it.
3. Creating a VPC
When creating a VPC, you must specify its IP address range.
For example:
VPC Name: Production-VPCIPv4 CIDR: 10.0.0.0/16This gives the VPC a total IPv4 address space of 65,536 addresses.
You can divide this range into smaller subnet ranges.
For example:
Production VPC10.0.0.0/16
Public Subnet A 10.0.1.0/24Private Subnet A 10.0.2.0/24Public Subnet B 10.0.3.0/24Private Subnet B 10.0.4.0/24The subnet ranges must fit inside the VPC address range and must not overlap with one another.
Planning the CIDR range properly is important because changing network address allocations later can require significant migration work.
4. What are Subnets?
A subnet is a smaller network inside a VPC.
Each subnet contains a range of IP addresses and belongs to exactly one Availability Zone.
Subnets help separate resources based on their networking requirements.
There are three commonly discussed subnet categories.
Public Subnet
A public subnet has a route to an Internet Gateway.
Resources can communicate directly with the internet when their IP addressing and security configurations allow it.
Typical resources include:
- Public web servers.
- Application Load Balancers.
- NAT Gateways.
- Bastion hosts.
Private Subnet
A private subnet does not have a direct route to an Internet Gateway.
It is commonly used for backend servers, application services, and internal workloads.
Private resources may still access the internet through a NAT Gateway when the necessary routing is configured.
Isolated Subnet
An isolated subnet has no route to destinations outside its VPC.
It is useful for resources that must remain within a restricted network environment.
For example, an organization may place sensitive database workloads in an isolated subnet.
5. Understanding Availability Zones
An AWS Region contains multiple Availability Zones.
Availability Zones are isolated infrastructure locations within a Region.
A VPC can span multiple Availability Zones, but each subnet belongs to only one Availability Zone.
Why does this matter?
Suppose your entire application runs in one Availability Zone.
If that Availability Zone becomes unavailable, your application may experience downtime.
By deploying resources across multiple Availability Zones, you can improve application availability and support failover.
For example:
AWS VPC 10.0.0.0/16 | +---------+---------+ | | v v AZ-A AZ-B | | Public Subnet Public Subnet | | Web EC2 Web EC2 | | Private Subnet Private Subnet | | App Server App ServerThe application must also be designed to tolerate failures; simply creating multiple subnets does not automatically provide high availability.
6. Route Tables
A route table determines where network traffic should be sent.
Each route contains:
- Destination: The IP range or prefix the traffic is intended for.
- Target: The next network destination.
Example:
Destination | Target |
|---|---|
10.0.0.0/16 | local |
0.0.0.0/0 | Internet Gateway |
The local route enables communication within the VPC.
The default route sends other IPv4 traffic towards the Internet Gateway.
You can create different route tables for different subnets.
For example, a private subnet can use a NAT Gateway as its default route instead of an Internet Gateway.
This allows different parts of the same VPC to have different network connectivity.
7. Internet Gateway
An Internet Gateway connects a VPC to the internet.
It must first be attached to the VPC.
A public subnet's route table must then contain a route directing internet-bound IPv4 traffic to the Internet Gateway.
Example:
INTERNET | | Internet Gateway | | Public VPC | | EC2An Internet Gateway is not sufficient by itself to make an EC2 instance publicly reachable.
The instance also needs suitable public addressing, route configuration, Security Group rules, and any applicable NACL permissions.
8. NAT Gateway
A NAT Gateway allows resources in private subnets to initiate outbound IPv4 connections to external networks without requiring individual public IPv4 addresses.
For example, a private backend server might need to download software updates.
Its route table directs internet-bound traffic towards a NAT Gateway in a public subnet.
INTERNET | Internet Gateway | NAT Gateway | Public Subnet | Private Route | Private EC2The NAT Gateway performs network address translation for the private resource's outgoing traffic.
It does not permit unsolicited inbound internet connections to the private instance.
9. Security Groups and Network ACLs
AWS uses two important network security mechanisms.
Security Groups
A Security Group operates at the network interface level.
It controls inbound and outbound traffic and is stateful.
You specify which traffic is permitted.
Network ACLs
A Network ACL operates at the subnet level.
It supports both allow and deny rules and is stateless.
You must account for both request and response traffic.
Feature | Security Group | Network ACL |
|---|---|---|
Scope | Network interface | Subnet |
Stateful | Yes | No |
Allow rules | Yes | Yes |
Deny rules | No | Yes |
Rule evaluation | All applicable rules | Numbered order |
These mechanisms work together to provide network-level protection.
10. Practical VPC Use Case
Imagine building a student placement platform.
It contains three major components:
- A frontend website.
- A backend API.
- A database.
A suitable network structure might be:
INTERNET | Internet Gateway | Public Subnet | Application Load Balancer | Private Subnet | Backend API | Database Subnet | RDS DatabaseThe frontend receives external traffic through the load balancer.
The backend processes requests and communicates with the database using private networking.
The database is not directly exposed to public users.
This separation improves security and makes the architecture easier to manage.
11. Best Practices
- Plan your VPC CIDR ranges before deploying resources.
- Use multiple Availability Zones for critical workloads.
- Keep databases and internal services private.
- Apply least-privilege Security Group rules.
- Avoid exposing administrative ports publicly.
- Use VPC Flow Logs for network visibility.
- Consider VPC endpoints for private access to supported AWS services.
- Monitor networking costs, especially NAT Gateway usage.
Conclusion
Amazon VPC is one of the most important building blocks of AWS infrastructure.
It provides the foundation for designing isolated, secure, and scalable cloud networks.
Understanding how CIDR ranges, subnets, routing, gateways, and security controls work together is essential before deploying real-world applications.
A well-designed VPC does more than connect resources. It defines how an application communicates, how its data is protected, and how its infrastructure can grow.
Build the network first. Build the application on a strong foundation.
Further Reading
- VPC subnet basics: https://docs.aws.amazon.com/vpc/latest/userguide/vpc-subnet-basics.html
- Internet Gateways: https://docs.aws.amazon.com/vpc/latest/userguide/VPC\_Internet\_Gateway.html
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article