Study HashiCorp Terraform 004 Resource Graph: key concepts, common traps, and exam decision cues.
Terraform is not just running commands one by one. It builds an internal graph of resources and references so it can determine ordering. This is why review discipline matters: Terraform is reasoning about relationships, not just executing a flat script.
| Terraform behavior | Why it matters |
|---|---|
| references create dependencies | Terraform can infer many ordering requirements automatically |
| graph-based planning | Terraform reasons about how objects relate before changing them |
| explicit dependency only when needed | depends_on is usually for hidden dependencies, not everything |
| Review habit | What it prevents |
|---|---|
| read the plan before apply | avoid blind changes |
| check why a dependency exists | avoid unnecessary depends_on usage |
| distinguish intended change from drift | avoid misreading plan output |
| Trap | Better rule |
|---|---|
| thinking Terraform needs explicit dependency declarations everywhere | references often give Terraform enough information already |
| treating the plan like plain text without meaning | the plan reflects Terraform’s graph reasoning |
| assuming graph order is the same as file order | dependencies matter more than where a block appears in a file |
Dependency questions usually come down to whether Terraform can infer the relationship from references. If it can, let the graph do the work. If it cannot, use depends_on sparingly for the real hidden dependency. Do not assume file order controls execution. Terraform cares about dependency edges, not the sequence in which you typed blocks into files.