depends_on meta-argument
The depends_on argument, which tells Terraform one resource must wait for another when no reference shows that relationship.
In more detail
Terraform infers almost all ordering from references, so depends_on is only for real but hidden relationships, such as a permission that must exist before a service can use it. Overusing it makes plans slower and more conservative, because more values stay unknown until apply.
Example
depends_on = [null_resource.network]Related terms
- implicit dependency — An ordering between two resources that Terraform works out for itself because one refers to the other.
- meta-argument — An argument Terraform itself understands on any resource or module block, such as count, for_each, depends_on, provider and lifecycle.
- dependency graph — Terraform's internal map of every resource, data source and value in a configuration, linked by which depends on which.
Related guides
Taught in
- Querying Existing Infrastructure With Data Sources — Infrastructure as Code with Terraform
- Explicit Dependencies With Depends On — Infrastructure as Code with Terraform
- Resources, Data Sources And The References Between Them — HashiCorp Terraform Associate (004) Exam Prep
- Count, For Each And Dynamic Blocks — HashiCorp Terraform Associate (004) Exam Prep
- Dependencies, depends_on And Lifecycle Rules — HashiCorp Terraform Associate (004) Exam Prep
- Custom Conditions: Validation, Pre And Postconditions, Checks — HashiCorp Terraform Associate (004) Exam Prep
- Module Scope: What Goes In, What Comes Out — HashiCorp Terraform Associate (004) Exam Prep
- Drift: When Reality Stops Matching State — HashiCorp Terraform Associate (004) Exam Prep
- Runs In HCP Terraform: The cloud Block And Remote Execution — HashiCorp Terraform Associate (004) Exam Prep
- Trap Sprint: Twelve Answers That Are Almost True — HashiCorp Terraform Associate (004) Exam Prep