Field Guides / Terraform on AWS
Field Guide · Beginner to Intermediate · 12-15 hours with labsTerraform on AWS: From First Resource to Production Modules
Go from your first S3 bucket to tested, versioned AWS modules shipped by an OIDC pipeline, with state, refactoring and drift handled properly.




97
pages
pages
12
hands-on labs
hands-on labs
31
interview Q&As
interview Q&As
13
chapters
chapters
This is for you if
- You can write basic Terraform but want to design and own a production codebase
- You inherited messy state and need to refactor or split it without destroying anything
- You want an AWS pipeline with no stored access keys
- You are preparing for DevOps, SRE or platform interviews where Terraform comes up
What's inside
- The mental model: configuration, state and reality, and how to read a plan like a reviewer
- S3 backend with native locking (use_lockfile), a hardened state bucket and migration off DynamoDB
- Workspaces versus separate roots, and splitting state by layer to limit blast radius
- Variables, validation, for_each versus count, data sources and guardrails like preconditions and checks
- A full VPC network module lab: multi-AZ subnets, NAT cost toggle, S3 endpoint, EKS-ready tags
- Config-driven refactoring with import, moved and removed blocks, including moving resources between states
- Testing with terraform test and mock providers, tflint, checkov and pre-commit
- GitHub Actions plan and apply with OIDC, separate plan and apply roles, and scheduled drift detection
- Troubleshooting playbook, production checklist, OpenTofu notes, cheat sheet and a 30-day plan
After this guide you can
- Set up remote state on S3 with locking and recover from stuck locks or deleted state
- Design, test and version a reusable module that other teams can consume safely
- Refactor live infrastructure with clean plans: no surprise destroys
- Build a keyless CI/CD pipeline for Terraform on AWS with GitHub OIDC
- Detect and resolve drift, and explain every design decision in an interview
Contents
- The mental model: how Terraform really worksp. 4
- Providers, authentication and versionsp. 9
- State: S3 backend, locking and environmentsp. 16
- The language: variables, locals, outputs, loops and datap. 27
- Module design and the VPC network labp. 36
- Refactoring safely: import, moved and removedp. 49
- Testing: validate, tflint, checkov and terraform testp. 57
- CI/CD with GitHub OIDC, and driftp. 66
- Troubleshooting playbookp. 79
- Production checklist and design decisionsp. 82
- Interview questionsp. 85
- Cheat sheetp. 92
- 30-day practice planp. 95
Written by Randy, a Senior Platform Engineer & SRE who runs production platforms on AWS, GCP and Azure. Companion to the Techworld with Randy episode Terraform on AWS.