Terraform / OpenTofu
Cheat sheet · https://pcornel.dk/topic.php?topic=787
Answer
Terraform and OpenTofu are separate IaC implementations that evaluate HCL-style configuration, resolve providers/modules, maintain state and execute dependency-aware plans against infrastructure APIs.
Remember
- Terraform/OpenTofu similarity ≠ universal interchangeability; behavior, features, registries and compatibility must be verified against pinned tool/provider/module versions.
- Terraform/OpenTofu command success ≠ target workload health; provider operations and application acceptance are separate proof boundaries.
- The same repository ≠ same run when binary, provider/module versions, backend/workspace, variables, credentials or lock selections differ.
- Treat Terraform and OpenTofu as separate implementations: verify behavior against the pinned tool and dependency versions rather than assuming interchangeability.
First checks
terraform version / tofu version— CLI and provider versionsterraform fmt -check && terraform validate— static checksterraform plan— preview
Commands
terraform fmt- Format Terraform files to the standard style.
terraform show- Show the current state or a saved plan.
Verify in this order
HCL → init → plan → apply → state
Where it usually breaks
Terraform/OpenTofu similarity ≠ universal interchangeability; behavior, features, registries and compatibility must be verified against pinned tool/provider/module versions. The proof boundary ends where provider/state evidence stops and target-domain acceptance begins.
Automation/controller success is not target-state proof; target config/state is not effective-runtime proof; effective state is not workload proof.
Terraform evidence chain
| Boundary | Question | Evidence | Does not prove |
|---|---|---|---|
| Definition | What is configured or intended? | running configuration / controller policy | live operation |
| Local state | Is the feature active at the expected scope? | terraform plan | remote success |
| Counters | Did controlled traffic or an event reach this stage? | scoped counters/timestamps | complete return path |
| Next boundary | What consumes or transports this state? | source of truth/input → schema/model → authentication/authorization → plan/diff → controlled execution → task/result → realized-state assertion | application success |
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=787