Automation · Terraform / OpenTofu
Dependencies
Cheat sheet · https://pcornel.dk/topic.php?topic=5460
Answer
Terraform/OpenTofu dependencies arise primarily from expression references and may be supplemented by explicit dependency metadata when no data reference exists.
Remember
- depends_on ≠ service readiness check; it changes graph ordering/unknown propagation but does not verify application acceptance.
- 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 graph | dot -Tpng > g.png— graph- depends_on usage review — necessary only
- Module dependencies via outputs — wiring
Verify in this order
references → graph → apply order
Where it usually breaks
depends_on ≠ service readiness check; it changes graph ordering/unknown propagation but does not verify application acceptance. The proof boundary ends where provider/state evidence stops and target-domain acceptance begins.
Dependencies IaC proof-boundary map
| Boundary | Healthy evidence | Suspicious evidence |
|---|---|---|
| Definition / inputs | Exact revision, toolchain and effective inputs are reproducible | Different runner/version/input context changes evaluation |
| State / planning | Correct backend/state/lock, fresh reads and reviewed graph/plan | Wrong state/workspace, stale reads, unsafe replacement/destroy or missing lock |
| Execution | Expected provider/API operations complete and state persists | Partial apply, auth/API error, ambiguous retry or failed state write |
| Target proof | Independent read-back plus fresh plan confirm intended convergence | Engine success treated as workload acceptance or drift remains unexplained |
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5460