4.2.2. Implicit vs. Explicit Dependencies
💡 First Principle: Terraform builds its dependency graph automatically from references (implicit dependencies); depends_on exists only to declare the dependencies Terraform can't see — relationships that exist in the real world but not in your configuration's data flow.
An implicit dependency is created whenever one block references another's attribute. This covers nearly everything and is the preferred approach because it's self-documenting and accurate. An explicit dependency uses the depends_on meta-argument to force ordering when there's a hidden relationship — for example, an application that needs an IAM policy to exist before it runs, even though the app resource doesn't reference the policy's attributes.
⚠️ Exam Trap: Overusing depends_on is an anti-pattern the exam may probe: it can force unnecessary serialization and obscure the real data flow. The correct guidance is "prefer implicit dependencies via references; use depends_on only for hidden dependencies." If an answer says you should always declare depends_on for safety, it's wrong.
Reflection Question: Give an example of a real dependency between two resources that a reference cannot express — and explain why depends_on is the right tool there.