7.2. Inspecting and Troubleshooting
💡 First Principle: When behavior surprises you, the fastest path to truth is looking at what Terraform records and what it logs — state inspection shows the current mapping, and verbose logging shows the decision process — so both are windows into the reconciliation engine, not changes to it.
Why care: State inspection and logging are exam objectives (7b and 7c) and core troubleshooting skills. The key facts are that state commands are read-or-record operations that never touch infrastructure, and that logging is controlled by environment variables.
The mental model: State inspection is reading the ledger; logging is turning on the security camera. Neither alters the building — they let you see what's recorded and what happened.
⚠️ Common Misconception: "terraform state commands change my infrastructure." They operate only on the state file's record. state rm stops Terraform managing a resource but doesn't destroy it; state mv renames an address but doesn't move anything real.