How to Set Up a Virtual Private Cloud: A Step‑by‑Step Guide
A Virtual Private Cloud (VPC) gives you a logically isolated network within a public cloud provider, such as AWS, Google Cloud, or Azure. Setting up a VPC allows you to launch resources in a controlled environment with custom IP ranges, subnets, and security rules. This tutorial walks through the essential steps for any major cloud platform.
Before you begin, decide on your IP address range (CIDR block) and plan your subnets – typically a public subnet for internet‑facing resources and a private subnet for databases or internal services. Most providers offer a default VPC, but creating a custom one ensures full control.
1. Create the VPC and Subnets
Navigate to your cloud console’s VPC dashboard. Click Create VPC and specify:
- Name tag – e.g., my-production-vpc
- IPv4 CIDR block – e.g., 10.0.0.0/16
- Tenancy (if applicable) – default or dedicated
After the VPC is created, add subnets. For each subnet, choose an Availability Zone and a smaller CIDR (e.g., 10.0.1.0/24 for public, 10.0.2.0/24 for private).
2. Configure Routing and Internet Access
Create an Internet Gateway and attach it to your VPC. Then edit the route table associated with your public subnet(s) to add a route:
- Destination:
0.0.0.0/0 - Target: the Internet Gateway ID
For private subnets, no direct internet route is needed – use a NAT Gateway if private resources must access the internet.
3. Set Up Security Controls
Protect your VPC with two layers:
- Security groups – stateful firewalls attached to instances. Allow only necessary inbound traffic (e.g., HTTP, SSH).
- Network ACLs – stateless rules for subnet boundaries. Deny all traffic by default then allow specific IP ranges.
Test connectivity by launching a test instance in the public subnet and verifying internet access. Then launch a private instance and confirm it cannot be reached from outside, but can communicate with the public subnet if needed.
Conclusion
You have now set up a functional VPC with separate subnets, routing, and security. This foundation lets you deploy web servers, databases, and microservices securely. Regularly review your rules and adjust CIDR blocks as your infrastructure grows.