Lesson 1 of 4 ยท AWS with Terraform

AWS VPCs and subnets

In AWS, a VPC is your network boundary and subnets divide it into workload areas. Start with a VPC, then add intentional public and private subnets before attaching application services.

Example

resource "aws_vpc" "main" {
  cidr_block = "10.0.0.0/16"
}

resource "aws_subnet" "public" {
  vpc_id     = aws_vpc.main.id
  cidr_block = "10.0.1.0/24"
}

Step by step

  1. Create the VPC.
  2. Create subnets inside its CIDR range.
  3. Decide which workloads belong in each subnet.
  4. Review routes before exposing services.

Common mistakes to avoid

  • Using a subnet CIDR outside the VPC range.
  • Placing databases beside public entry points by default.