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
# 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$ 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) subnets5-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.