Language

AWS VPC · Lesson 13 of 30

Build VPC with Terraform

Source: doonops-curriculum/aws-vpc--vpc-terraform.md

Doonops lesson

Goal

Build VPC using official module — do not hand-write 20 subnet resources on day one.

Simple explanation

Module = pre-built LEGO kit for VPC. You pass cidr, azs, subnet lists — module builds IGW, routes, NAT.

Technical view

Module = pre-built LEGO kit for VPC. You pass cidr, azs, subnet lists — module builds IGW, routes, NAT.

Think of it like

Module = pre-built LEGO kit for VPC. You pass cidr, azs, subnet lists — module builds IGW, routes, NAT.

Steps

  1. Read simple section
  2. Read analogy + diagram
  3. Copy project files
  4. Do local lab

Deep explanation

Layman words first, then technical detail — read slowly

Module terraform-aws-modules/vpc/aws saves time. Pin version ~> 5.0.

Hand-writing every subnet is exam knowledge; modules are real job skill.

Example (Doonops)

Modern HCL — names are examples, not from any third-party course

Example HCL
HCL
module "vpc" {
  source  = "terraform-aws-modules/vpc/aws"
  version = "~> 5.0"
  name = "doonops-vpc"
  cidr = "10.1.0.0/16"
  azs  = ["ap-south-1a"]
  public_subnets  = ["10.1.1.0/24"]
  private_subnets = ["10.1.2.0/24"]
}

Terraform runs on your computer — copy this HCL into a folder, then follow the local lab steps below.

Quick check

  • Explain topic to a friend in 2 sentences
  • Did local lab steps

Project files for this lab

Full implementation folder — copy all files, then run terraform commands

Lab project files (full folder)

Copy every file below into one folder — same as a real repo module. Then run the local lab steps.

Suggested folder: Suggested path: ~/doonops-terraform/10-vpc-terraform/

versions.tfSee file purpose in the code below
terraform {
  required_version = ">= 1.9.0"
}

Module check — did you get it?

2–3 quick questions before the next module

VPC — quick check

Quick check — did this module stick?

1. A VPC is…

  • A single EC2 instance
  • Your private network boundary in AWS
  • Only a database
  • A DNS name