Terraform Tutorials
Terraform from the ground up — the plan/apply loop, HCL, providers and state, variables, modules and remote state, then deploying a real Spring Boot API to AWS ECS Fargate behind a load balancer with a GitHub Actions pipeline. Written against Terraform 1.15 and AWS provider 6.x, and every stack in it was applied to a real account before it was written about.
- Terraform – Interview QuestionsThe questions Terraform interviews actually ask, answered the way you would say them out loud. What state is for, `count` versus `for_each`, how locking works, module versioning, what happens when someone changes something in the console, Terraform versus CloudFormation versus Ansible, and how you would recover a corrupted state file.
- Terraform – Running It in ProductionWhat changes when the state file matters. Reading a plan properly and the three words that should stop a merge, `prevent_destroy` on the things you cannot lose, drift and what to do about it, secrets in SSM instead of variables, `moved` and `import` for refactoring without destroying, least-privilege CI credentials, keeping the bill visible, and `terraform test`.
- Terraform – A CI/CD Pipeline in GitHub ActionsPlan on the pull request, apply on merge, and no AWS keys stored anywhere. Configuring GitHub's OIDC provider and the IAM role it assumes, posting the plan as a PR comment, the image build and push to ECR, rolling the ECS service onto the new image, and the concurrency group that stops two applies running at once.
- Terraform – Deploying a Spring Boot API to ECS FargateThe second half. An ECR repository, a Fargate task definition with the environment and secrets the app needs, an ECS service, an application load balancer with a target group and health check, and CloudWatch logs — deploying the real pizza-springboot-backend image. Including what the health check has to point at, and why the first deploy sat in PENDING.
- Terraform with AWS – Building the Network and DatabaseThe first half of a real deployment. A VPC with public and private subnets across two availability zones, an internet gateway and route tables, security groups that reference each other instead of hard-coding CIDRs, and an RDS MySQL instance for the pizza API — with the database password kept out of both the code and the state file.
- Terraform – Dev, Staging and Prod Without Copy-PasteThree ways to run the same configuration against three environments: workspaces, separate directories with a shared module, and one directory with per-environment `.tfvars` and backend config. What each actually gives you, why workspaces are a trap for prod specifically, and the layout that survives the fourth environment.
- Terraform – Writing and Using ModulesA module is a directory of Terraform you can call more than once. Structuring one, its inputs and outputs, calling a local module and a registry module, pinning a module version, what `terraform get` does — and an honest section on when a module is the wrong answer and a bit of duplication is cheaper than the abstraction.
- Terraform – count, for_each and Dynamic BlocksThree subnets should not be three copy-pasted blocks. `count` and its index, `for_each` over a map or a set, and the specific reason `count` will destroy and recreate half your resources when you remove one from the middle of a list. Then `for` expressions, `dynamic` blocks for repeated nested blocks, and the conditional expression.
- Terraform – Remote State and Locking on S3Local state works until there are two of you, then it corrupts. The S3 backend, native state locking with `use_lockfile` — and why every tutorial you will find still tells you to create a DynamoDB table that Terraform 1.11 deprecated. Bootstrapping the bucket that holds the state, versioning and encryption on it, and migrating a local state file into it without losing anything.
- Terraform – Data Sources and Reading Existing InfrastructureNot everything you reference is something you created. Data sources read what is already there — the latest AMI, the availability zones in this region, an existing VPC, another stack's remote state. When a data source is the right answer, when importing the resource is, and the hard-coded AMI id that stopped existing.
- Terraform – Variables, Locals and OutputsOne configuration, many environments. Typed input variables and why you should always declare the type, `validation` blocks that reject a bad value at plan time, `sensitive` and what it does and does not hide, `.tfvars` files, the full precedence order when the same variable is set four ways, locals, and outputs.
- Terraform – Resources and the State FileState is the thing people misunderstand and then get burned by. What Terraform stores and why it cannot work without it, how resource addresses map to real infrastructure, implicit dependencies versus `depends_on`, the `lifecycle` block including `prevent_destroy`, and the `terraform state` subcommands you reach for when the file and reality disagree.
- Terraform – Providers, Versions and the Lock FileA provider is the plugin that knows how to talk to AWS, and pinning it is the difference between a reproducible build and a surprise on Tuesday. `required_providers`, version constraint operators and which one to use, what `.terraform.lock.hcl` is for and why it belongs in git, provider aliases, and deploying to two regions from one configuration.
- Terraform – HCL Syntax You Will Actually UseHCL is small, and this is the part of it you need. Blocks and arguments, the type system, string interpolation and heredocs, the functions worth memorising, `terraform console` for trying an expression without an apply, and `terraform fmt` so nobody reviews your indentation.
- Terraform – Install It and Run Your First ApplyInstall Terraform, point it at AWS, and create something real. The four commands the whole tool is built around — `init`, `plan`, `apply`, `destroy` — what each one actually does, how to read a plan before you approve it, and why `init` downloads hundreds of megabytes the first time and nothing the second.
- Terraform – What It Is and Why It ExistsStart here. What infrastructure as code actually buys you over clicking around a console, where Terraform sits next to CloudFormation, CDK, Pulumi and Ansible, the 2023 licence change and what OpenTofu is, the exact versions this track is written against, the application the AWS lessons deploy, and the full lesson index in reading order.