← Back to Blog

Understanding AWS VPCs and Subnets

May 22, 2024

Building My Own Private Corner of the Cloud



If EC2 instances are the houses, then the Virtual Private Cloud (VPC) is the land and city planning. It's your own logically isolated section of the AWS Cloud where you can launch AWS resources.

I learned that you can't just throw servers out there; you need a network. A VPC provides that. Here's what I've grasped so far:

- **VPC**: A virtual network dedicated to your AWS account.
- **Subnet**: A range of IP addresses in your VPC. Resources like EC2 instances are launched into subnets.
- **Internet Gateway**: A gateway that you attach to your VPC to enable communication between resources in your VPC and the internet.
- **Route Tables**: A set of rules, called routes, that are used to determine where network traffic is directed.

I created a custom VPC with two types of subnets:

**Public Subnet**: This subnet's traffic is routed to an Internet Gateway. Instances here, like a web server, can be accessed from the internet.

**Private Subnet**: This subnet does not have a direct route to the Internet Gateway. Instances here, like a database server, are not directly accessible from the outside world, which is great for security.

Here is a simplified representation of a route table for a public subnet:

{
"Routes": [
{
"DestinationCidrBlock": "10.0.0.0/16",
"GatewayId": "local",
"State": "active"
},
{
"DestinationCidrBlock": "0.0.0.0/0",
"GatewayId": "igw-xxxxxxxx",
"State": "active"
}
]
}


The 0.0.0.0/0 destination represents all internet traffic, and it's being pointed to the Internet Gateway (igw-...). This is what makes the subnet "public".

Understanding this fundamental networking layer feels like unlocking a new level in my cloud journey. It's the foundation upon which secure and scalable applications are built.