Thuta Learning
IntermediateDevOpsbeginner

VPC Basics (Virtual Private Cloud)

Relax. We'll talk through this in plain words — no textbook voice.

What you'll walk away with

  • Understand VPC Basics (Virtual Private Cloud) without the intimidation
  • Be able to run the AWS CLI/Console yourself
  • Apply this concept immediately in a real project

Let's think about this for a second

A VPC (Virtual Private Cloud) lets you create your own private network (with a defined IP address range) within an AWS Region — you place your resources (EC2, RDS) inside this network. A Subnet is a smaller chunk of IP range carved out of the VPC — it's common to split them into a Public Subnet (connects to the internet through an Internet Gateway, for web servers) and a Private Subnet (not directly reachable from the internet, for databases). A Route Table is the set of rules deciding where traffic inside a subnet gets routed (out through the Internet Gateway, or staying within the VPC).

Let's connect this to a real scenario

When deploying a three-tier web app (frontend + backend + database) inside a VPC — you'd put the frontend/backend EC2 instances in a Public Subnet to accept traffic from the internet, and put the database (RDS) in a Private Subnet so it's protected from direct internet access (only the backend server is allowed to connect to it).

Let's look at it together

bash
# Create a VPC with a 10.0.0.0/16 IP range
aws ec2 create-vpc --cidr-block 10.0.0.0/16

# Create a public subnet inside it
aws ec2 create-subnet --vpc-id vpc-0123456789abcdef0 --cidr-block 10.0.1.0/24

# Create a private subnet for the database tier
aws ec2 create-subnet --vpc-id vpc-0123456789abcdef0 --cidr-block 10.0.2.0/24
You should see
$ aws ec2 describe-subnets --filters Name=vpc-id,Values=vpc-0123456789abcdef0
# Shows both the 10.0.1.0/24 (public) and 10.0.2.0/24 (private) subnets

5-minute try-it

Create a VPC (10.0.0.0/16) and split it into 2 subnets (public/private) — check out the VPC diagram view in the AWS Console to visualize the layout.

A quick word of caution

Instead of using the Default VPC (auto-created when you create your AWS account) for production, you should use a custom VPC that you've designed yourself.

Easy traps

  • Putting a database (RDS) in a Public Subnet — this leaves it open to direct attacks from the internet
  • Picking the same IP range for two unrelated VPCs/projects — if you ever need to connect the two VPCs later (VPC Peering), you'll run into IP conflicts

Now try it yourself

Create a VPC (10.0.0.0/16) and split it into 2 subnets (public/private) — check out the VPC diagram view in the AWS Console to visualize the layout.

You'll know it worked when: $ aws ec2 describe-subnets --filters Name=vpc-id,Values=vpc-0123456789abcdef0 # Shows both the 10.0.1.0/24 (public) and 10.0.2.0/24 (private) subnets

VPC Basics (Virtual Private Cloud) | Thuta Learning