Skill 4.6.1

Implicit dependencies

Key Concepts

When one block's arguments refer to another block, as in subnet_id = aws_subnet.app.id, Terraform adds an edge to the dependency graph and creates the subnet before the instance. When the instance is destroyed, it is destroyed before the subnet. These implicit dependencies are the preferred way to express ordering, because the reference documents why the order matters.

Dependencies also determine parallelism: resources with no path between them in the graph are created at the same time. Terraform reports an error if references form a cycle, which usually means two resources should be split, for example by using a separate rule resource instead of inline rules.