intermediate 5-6h

Terraform AWS VPC

Provision a production-shaped VPC with public/private subnets.

0%

0 of 6 steps

What you will end up with

A reusable VPC module

Public and private subnets

Remote, locked state

Build steps

0/6

Configure an S3 bucket plus a DynamoDB table in the backend block of your config. The lock stops two people from editing the same state file at once, like a bathroom door lock.

Write an aws_vpc resource and a handful of aws_subnet resources with different CIDR ranges. The VPC is the whole apartment building, subnets are the individual floors.

Attach an aws_internet_gateway for public subnets and a NAT gateway for private ones. The internet gateway is the building’s front door, NAT is a one-way mail slot for the private floors.

Create route tables that send 0.0.0.0/0 traffic to the internet gateway for public subnets, or the NAT gateway for private ones, then associate each subnet. Route tables are the signposts telling traffic which door to use.

Move hardcoded values into variables.tf using variable blocks, then reference them as var.name elsewhere. It swaps hardcoded numbers for labeled sliders you can adjust without touching the logic.

Move the VPC resources into a modules/vpc folder with its own inputs and outputs, then call it with a module block from the root. It is boxing up a recipe so you can reuse it in any kitchen.

Before you start

HCL & providersState & backendsCloud networking