Certifications Tools Exam Guides Blog Pricing
Start for free
Terraform

Terraform Implicit vs Explicit Dependencies — Why This Confusion Fails So Many Associate Exams

You knew Terraform. You’ve deployed production infrastructure. But the exam still caught you off guard with questions about resource ordering and dependencies. The problem isn’t your Terraform skills—it’s the gap between how humans think about dependencies and how Terraform actually resolves them.

Terraform Associate (003) questions about dependencies are designed to expose this gap. They present scenarios where the “obvious” answer is wrong because Terraform’s internal graph doesn’t match human intuition. Understanding this mismatch is often the difference between failing at 68% and passing at 75%.

What Terraform Actually Considers a Dependency

Before examining exam traps, you need to understand precisely what Terraform considers a dependency. Not what feels like a dependency—what Terraform actually tracks in its dependency graph.

Implicit Dependencies: References Create Order

Terraform creates an implicit dependency whenever one resource references an attribute of another resource. This is the primary mechanism for dependency resolution:

resource “aws_vpc” “main”

resource “aws_subnet” “public”

Because aws_subnet.public references aws_vpc.main.id, Terraform knows the VPC must exist before the subnet can be created. This is an implicit dependency—you didn’t declare it, Terraform inferred it from the reference.

Explicit Dependencies: Manual Override

When there’s no attribute reference but a dependency still exists, you use depends_on:

resource “aws_instance” “app”

The instance doesn’t reference the policy attachment’s attributes, but it needs the policy attached before the instance can function correctly. depends_on forces Terraform to create the dependency relationship explicitly.

What Terraform Ignores

This is where exam traps live. Terraform does NOT create dependencies from:

  • Logical relationships: Just because a security group “should” exist before an instance doesn’t mean Terraform knows this unless there’s a reference
  • File order: Resources in the same file or different files are treated identically
  • Variable usage: Using the same variable in two resources creates no dependency between them
  • Resource naming conventions: web_server and web_security_group have no relationship to Terraform

Why the Exam Exploits This Confusion

HashiCorp designs dependency questions specifically to test whether you understand Terraform’s graph-based logic versus human intuition. The exam cannot assume you’ve internalized this distinction—so it tests it directly.

Human Logic vs Terraform Logic

ScenarioHuman AssumptionTerraform Reality
Security group and instance in same file”Security group will be created first”No dependency unless instance references SG
Two resources use same variable”They’re connected somehow”No relationship—variables don’t create dependencies
Resource A is defined before Resource B”A will be created before B”File order is irrelevant to Terraform
Output references a resource”Output creates dependency”Outputs don’t affect resource creation order
Module depends on another module’s output”Modules are independent”If Module B uses Module A’s output, implicit dependency exists

The exam exploits each of these gaps. When a question describes two resources that “feel” related, your job is to identify whether an actual reference exists—not whether the relationship makes logical sense.

Classic Terraform Associate Exam Traps

These patterns appear repeatedly in the exam. Recognizing them saves time and eliminates guesswork.

Trap 1: Resources Created in the “Wrong” Order

A question describes two resources where one should logically depend on the other, but there’s no attribute reference. The exam asks what happens during terraform apply.

What Terraform does: Creates both resources in parallel (or arbitrary order) because no dependency exists.

What candidates expect: Terraform “knows” the logical relationship and creates them in order.

Trap 2: Variables and Outputs That Do NOT Create Dependencies

variable “environment”

resource “aws_instance” “web” { tags = }

resource “aws_instance” “db” { tags = }

Both instances use var.environment, but they have no dependency on each other. Terraform can create them in any order or simultaneously. The variable is resolved before the graph is built—it doesn’t create resource relationships.

Trap 3: Misuse of depends_on

Questions sometimes present scenarios where depends_on is used unnecessarily (when an implicit dependency already exists) or where it’s missing (when no reference exists but order matters).

Exam logic: Use depends_on only when no implicit dependency exists but ordering is required. Overusing it creates maintenance burden and can mask configuration errors.

Trap 4: Thinking File Order Matters

Terraform loads all .tf files in a directory and builds a single dependency graph. Whether resources are in main.tf, network.tf, or separate files has zero impact on creation order.

If an exam question mentions file organization, it’s usually a distractor. Focus on references and depends_on, not file structure.

If You See This in a Question, Think This

Use these mental shortcuts during the exam to quickly identify the correct answer:

Dependency Decision Framework

  • “Resource A uses Resource B’s attribute” → Implicit dependency exists (A depends on B)
  • “No reference between resources” → No dependency (parallel creation possible)
  • “depends_on is specified” → Explicit override forces ordering
  • “Resources share a variable” → No dependency (variables don’t create relationships)
  • “Resources in same file” → Irrelevant (file order doesn’t matter)
  • “Output references a resource” → Doesn’t affect resource creation order

When reading exam questions, scan for attribute references first. If resource_type.resource_name.attribute appears in another resource’s configuration, an implicit dependency exists. If not, assume parallel execution unless depends_on is present.

How to Fix This Before Your Retake

If dependency questions caused your failure, targeted practice on graph logic—not more general Terraform study—will improve your score.

Step 1: Use terraform graph to Visualize Dependencies

Run terraform graph on your configurations and trace the edges. This makes implicit dependencies visible and helps you internalize what Terraform actually sees.

terraform graph | dot -Tpng > graph.png

For each edge in the graph, identify the reference that created it. If there’s no edge between two resources you expected to be related, ask yourself why.

Step 2: Practice Reading Plan Output

Before terraform apply, the plan output shows creation order. Practice predicting this order before running terraform plan, then verify your predictions.

Step 3: Stop Trusting Intuition

Your production experience may have trained you to assume dependencies that don’t exist in Terraform’s model. For the exam, treat every dependency as “guilty until proven innocent”—assume no relationship unless you can point to a specific reference or depends_on.

Step 4: Practice Scenario-Based Questions

Flashcards won’t fix dependency confusion. You need questions that present configurations and ask about behavior. Practice identifying implicit dependencies, predicting creation order, and recognizing when depends_on is necessary.

Frequently Asked Questions

Does Terraform use file order to determine resource creation?

No. Terraform loads all .tf files in a directory and builds a single dependency graph. The order resources appear in files—or which files they’re in—has no impact on creation order. Only attribute references and depends_on declarations affect ordering.

Do variables create dependencies between resources?

No. Variables are resolved before the dependency graph is built. Two resources using the same variable have no dependency on each other—they simply share a resolved value. The variable itself doesn’t create any relationship between resources.

When should depends_on be used?

Use depends_on only when a dependency exists that Terraform cannot infer from attribute references. Common cases include IAM policies that must exist before resources can use them, or resources that interact through side effects (like a null_resource that configures another resource). Avoid using depends_on when an implicit dependency already exists through references.

Why did my resource create earlier than expected?

If a resource was created before another that you expected to depend on it, check whether an actual reference exists. Terraform creates resources in parallel when no dependency is detected. If you need ordering without an attribute reference, add depends_on to establish the relationship explicitly.

Can I visualize Terraform’s dependency graph?

Yes. Run terraform graph to output the dependency graph in DOT format. You can pipe this to Graphviz (dot -Tpng) to create a visual representation. This is an excellent study tool for understanding which dependencies Terraform actually detects versus which ones you assume exist.

Moving Forward

Failing dependency questions doesn’t mean you don’t understand Terraform. It means your mental model of dependencies doesn’t match Terraform’s graph-based logic. This is a common gap—and a fixable one.

The exam tests whether you can predict Terraform’s behavior based on configuration, not whether you can design elegant infrastructure. Reframe your preparation around graph logic: trace references, identify implicit dependencies, and recognize when depends_on is necessary versus redundant.

Structured practice that exposes you to dependency scenarios—not more video courses or documentation reading—will close this gap before your retake.