Virtual Private Cloud (VPC) (12 min)
What is a VPC?
A Virtual Private Cloud (VPC) is a logically isolated section of a public cloud where you can launch resources in a virtual network that you define, giving you control over IP address ranges, subnets, route tables, and network gateways.
Key Features of a VPC
VPCs allow you to create public and private subnets, configure security groups and network access control lists, and connect to on-premises networks through VPN or dedicated connections for hybrid cloud setups.
Why VPCs Matter
VPCs provide a secure, customizable networking environment that isolates your cloud resources from other customers, making them essential for building secure, compliant, and well-architected cloud applications.
Designing a VPC Step by Step
Most cloud providers follow a similar building-block model. AWS and Google Cloud call it a VPC, while Azure calls it a Virtual Network (VNet), but the planning steps are almost the same.
- Choose an address range. Pick a private CIDR block, such as
10.0.0.0/16, that does not overlap with your office network or other VPCs you may connect later. - Split it into subnets. Create smaller ranges, for example
10.0.1.0/24for public resources and10.0.2.0/24for private ones, ideally across more than one availability zone. - Attach an internet gateway if anything needs to be reachable from the internet.
- Set up route tables. A public subnet routes
0.0.0.0/0to the internet gateway; a private subnet does not. - Give private servers outbound access through a NAT gateway when they need to download updates without being reachable from outside.
- Apply firewall rules with security groups and network ACLs.
A Classic Three-Tier Layout
| Layer | Subnet type | Allowed inbound traffic |
|---|---|---|
| Load balancer | Public | HTTPS from the internet |
| Application servers | Private | App port, only from the load balancer's security group |
| Database | Private | Database port, only from the app servers' security group |
With this design, users can only reach the load balancer. Even if someone scans the internet, the app servers and database have no public route to them.
# Example with the AWS CLI (IDs are placeholders)
aws ec2 create-vpc --cidr-block 10.0.0.0/16
aws ec2 create-subnet --vpc-id vpc-123 --cidr-block 10.0.1.0/24
aws ec2 create-internet-gateway
aws ec2 attach-internet-gateway --vpc-id vpc-123 --internet-gateway-id igw-456
In real teams this is usually written as infrastructure as code with Terraform, CloudFormation or Bicep, so the network can be reviewed and recreated reliably.
Security Groups vs Network ACLs
On AWS, security groups are attached to individual resources and are stateful: if inbound traffic is allowed, the reply is allowed automatically. Network ACLs apply to a whole subnet, are stateless, and are checked rule by rule, so return traffic must be allowed explicitly. Use security groups as the main control and ACLs as an extra guard layer. Other providers have similar ideas under different names, such as network security groups on Azure and firewall rules on Google Cloud.
Mistakes to Avoid
- Choosing a CIDR range that overlaps with on-premises networks, which blocks VPN or peering later.
- Opening SSH or RDP to the whole internet; restrict to known IPs or use a managed access service.
- Putting databases in public subnets for convenience.
- Making subnets too small, leaving no room to grow.
- Skipping flow logs, which help you investigate unexpected traffic.
Ready to Master Cloud Computing?
Join Uncodemy's industry-recognized Cloud Computing Course and build in-demand cloud skills with expert mentors.
Explore Cloud Computing Course