Terraform & IaC
Variables, outputs and locals
One set of files, two environments: how variables, locals and outputs let the same code build staging and prod, and which source of values wins when two disagree.
What is in the lesson
- A real situation where this goes wrong
- How it works, step by step
- A walkthrough with commands you can run
- How it fails in production, and how to tell
- Three quiz questions with explanations
Read this lessonFree. No account needed.
More in Terraform & IaC
- Infrastructure as code: why and what declarative meansBeginner · 5 min
Why a security group nobody can explain is a bigger risk than one that is misconfigured, and how describing the end state in a file lets a tool find the gap for you.
- The Terraform workflow: init, plan, apply, destroyBeginner · 5 min
Four commands, one rule: read the output of the second before you run the third. Create a bucket, prove nothing is left to change, then delete it again.
- Terraform state: what it maps and why it mattersBeginner · 5 min
A pull request that only renames a resource label plans to delete a bucket holding 90 GB of logs. State explains why, and one moved block fixes it.
- Remote state and lockingBeginner · 5 min
Two engineers apply within seconds of each other. Without a shared state and a lock, one run overwrites the other's record. Here is how the second one gets stopped…
- Lifecycle ignore_changesBeginner · 4 min
Lifecycle ignore_changes suppresses plans for selected attribute drift.
- create_before_destroyBeginner · 4 min
create_before_destroy requests replacement creation before deletion.