AWS Builder Center
Day 5: Amazon VPC – Subnets, Route Tables, Gateways, and Network Security

Day 5: Amazon VPC – Subnets, Route Tables, Gateways, and Network Security

Day 5 of my 90-day AWS challenge: how Amazon VPC gives you a private network in the cloud, including CIDR blocks, public and private subnets, route tables, internet gateways, and the difference between security groups and NACLs.

Recap of Day 4

Yesterday I learned how S3 stores data. Today I'm learning where all these resources actually live: the network. That service is Amazon VPC.

What is a VPC?

A VPC (Virtual Private Cloud) is your own logically isolated network inside AWS. You decide the IP address range, create subnets, and control how traffic moves in and out. A VPC belongs to one Region and spans multiple Availability Zones.

Key components

ComponentWhat it does
CIDR blockThe IP range of the VPC, e.g. 10.0.0.0/16
SubnetA smaller slice of the VPC that lives in one Availability Zone
Route tableRules that decide where network traffic is sent
Internet Gateway (IGW)Connects the VPC to the internet
NAT GatewayLets private subnets reach the internet without being reachable from it

Public vs. private subnets

  • Public subnet: its route table has a route to an Internet Gateway, so resources can be reached from the internet (e.g., a web server)
  • Private subnet: no direct route to the internet (e.g., a database)

Security groups vs. NACLs

Security groupNetwork ACL (NACL)
LevelInstanceSubnet
StateStateful (return traffic is allowed automatically)Stateless (return traffic needs its own rule)
RulesAllow rules onlyAllow and deny rules

What I practiced today

  1. Looked at the default VPC that AWS creates in every Region
  2. Created a custom VPC with the CIDR block 10.0.0.0/16
  3. Created a public and a private subnet in different Availability Zones
  4. Attached an Internet Gateway and added a route to it in the public subnet's route table
  5. Cleaned up the resources when I was done

Key takeaways

  • Put public-facing resources in public subnets and databases in private subnets
  • Spread subnets across Availability Zones for resilience
  • NAT Gateways are billed by the hour, so delete them after practicing

Up next: Day 6

Amazon RDS: managed relational databases.
Learning AWS too? Follow along and share what you're building. #90DaysOfAWS
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article