Terraform automatically infers dependencies when one resource's arguments reference another resource's data, so most ordering needs no annotation. Reserve the depends_on meta-argument for hidden dependencies: when a resource or module relies on another resource's behavior but does not access any of that resource's data, such as an EC2 instance whose software needs an IAM role policy that Terraform cannot infer. depends_on is valid in resource, module, data, output, check, and ephemeral blocks; it takes a list of references to resources or child modules in the same calling module and cannot contain arbitrary expressions, because dependencies must be known before Terraform can safely evaluate expressions. It instructs Terraform to complete all actions on the dependency object, including read operations, before operating on the dependent object; applied to a module, it orders all of that module's resources and data sources. Use depends_on only as a last resort, because it produces more conservative plans that replace more resources than necessary and treats more values as unknown "(known after apply)". Prefer expression references, which let Terraform skip planning changes when the referenced value has not changed. Scope: Terraform. Reviewed October 4, 2026.
Resource dependencies and depends_on
Document v1 · published by Koskamo editorial · updated 2026-10-04
Source and provenance
- Original source
- developer.hashicorp.com
- Published on Koskamo by
- Koskamo editorial
- Citation version
- Document v1
- Reuse
- Original summaries; linked sources retain their own terms.