← Back to all projects

Build a Virtual Private Cloud

I built an Amazon VPC from scratch, with a public subnet that auto-assigns public IPv4 addresses, an Internet Gateway, and a custom route table.

The goal was hands-on practice with AWS networking basics: building, configuring and managing a secure, customizable cloud network.

How I built it

1. Creating the VPC

I created a custom VPC named my-VPC with the IPv4 CIDR block 192.168.0.0/16. The CIDR block sets the range of IP addresses available to my resources.

A VPC is a private, isolated virtual network inside AWS. In it I control the IP ranges, subnets, route tables, internet gateways and network security, and I decide what traffic comes in and goes out.

My account already had a default VPC, which AWS creates so beginners can launch resources like EC2 instances without building a network first.

my-VPC shown in the VPC console
Figure 1: my-VPC in the VPC console.

2. Creating a public subnet

I created a subnet named Public Subnet 1 with the CIDR block 192.168.1.0/24. A subnet is a smaller segment of the VPC's address range and lives in one Availability Zone, which makes resources easier to organize and spread across zones for better availability.

A subnet is public when its route table sends internet-bound traffic to an Internet Gateway. A private subnet has no direct route to one.

After creating it, I turned on auto-assign public IPv4 address. Now EC2 instances launched in this subnet get a public IP automatically, so I don't have to set it up for each instance.

Public Subnet 1 in the VPC console
Figure 2: Public Subnet 1 inside my-VPC.

3. Attaching an Internet Gateway

I created an Internet Gateway named my-igw and attached it to my-VPC. It is the connection point between my VPC and the public internet, and it allows inbound and outbound traffic once routing and security settings are in place.

Without it, resources in my public subnet would have no direct internet connection, even with public IP addresses.

my-igw attached to my-VPC
Figure 3: my-igw attached to my-VPC.

4. Setting up the route table

I created a custom route table named Public Route Table and associated it with Public Subnet 1. Then I added a route with destination 0.0.0.0/0 and the Internet Gateway as the target.

A route table is a set of rules that tell traffic where to go, matching a destination range to a target such as a gateway. With it, I control how my subnet's resources reach the internet or other networks.

Summary