DELAPARRA
Index
Color
NL
Category: Terraform

depends_on

Explained by Updated

What is depends_on?

depends_on: Forces an explicit ordering when Terraform can’t infer the dependency from references alone. In Terraform, depends_on sets an explicit order between resources when Terraform cannot see the dependency itself. Normally, referencing another resource's attribute is enough, and Terraform works out the order. Some dependencies are hidden. A server might need an access policy to exist before its start-up script runs, without referring to that policy anywhere in its configuration. Then depends_on = [aws_iam_role_policy.app] makes the order explicit.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about depends_on

What should you keep in mind with depends_on?

Use it sparingly. Every depends_on makes plans more conservative and can slow down applies. If you find many of them, check whether you can reference an attribute instead, which documents the relationship more clearly. When you do use it, add a short comment explaining the hidden dependency, because the reason is rarely obvious later.

What does an example of depends_on look like?

resource "aws_instance" "web" { depends_on = [aws_iam_role_policy.app] }

At a glance

CategoryTerraform
Explained by
Updated

More Terraform terms

All terms starting with D

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.