kb/debugging
Terraform debugging tools for when `apply` fails or `plan` shows something strange: TF_LOG=DEBUG for a verbose log, `terraform console` to check expressions interactively, `terraform validate` to check syntax without a cloud. Without them, debugging is guesswork.
A catalog of the Terraform errors you will hit again and again: cycle dependencies, "value depends on resource attributes that cannot be determined until apply", state lock, inconsistent plan, "for_each argument cannot include keys derived from resource attributes". For each one, the cause and the fix.
A plan shows a diff: `+` create, `~` update in place, `-/+` replace, `-` destroy, `<=` data read. The summary line at the bottom reads `Plan: X to add, Y to change, Z to destroy`. The rule that matters: a second plan after apply should be clean ("No changes").
`TF_LOG` is an environment variable. It turns on Terraform's diagnostic logs: internal steps, HTTP requests to the cloud, dependency resolution. The levels are TRACE, DEBUG, INFO, WARN, ERROR. For everyday work DEBUG is enough. TF_LOG_PATH writes the output to a file.