What you will learn
- Explain what state is
- Use remote backends
- Lock state safely
New to this? Start here
The basics, in plain English
Terraform needs to remember what it has already built so it knows what to change next time. It records this in a state file. This file is the single most important and sensitive part of using Terraform.
- State
- Terraform’s memory of what it has created, mapping your files to real resources.
- State file
- The actual file holding that memory. Lose it and Terraform gets confused.
- Backend
- Where the state file is stored, ideally a shared remote location, not your laptop.
- Locking
- Preventing two people from changing infrastructure at the same time and clashing.
- Why it matters
- The state can contain secrets and is the source of truth, so it must be protected.
01
The map
State maps your config to real resources. It is the source of truth and must be stored remotely (S3 + DynamoDB lock) so teams do not corrupt it.
Finished this topic?
Mark it done to earn 100 XP and keep your streak alive.