Courseiva
Use Terraform outside the core workflowmediumMatchingObjective-mapped

TF-004 Use Terraform outside the core workflow Practice Question

Match each Terraform meta-argument to its purpose.

Drag a concept onto its matching description — or click a concept then click the description.

Concepts
Matches

Create multiple instances from one resource block

Create multiple instances from a map or set of strings

Explicitly specify hidden resource dependencies

Control resource creation/destruction behavior

Select a non-default provider configuration

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

depends_on: Specifies hidden dependencies on other resources

Terraform meta-arguments are available across all resource types. depends_on declares hidden dependencies, count creates N copies, for_each creates copies from a collection, and lifecycle controls behavior like create_before_destroy. Common confusions include mixing the purposes of count and depends_on, or associating lifecycle with instance creation.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • depends_on: Specifies hidden dependencies on other resources

    Why this is correct

    The depends_on meta-argument is used to explicitly declare dependencies between resources that Terraform cannot automatically infer from resource attributes. This is crucial for situations where one resource's creation or modification must logically precede another, even if no direct attribute references exist. It ensures the correct ordering of operations, preventing potential race conditions or failures during terraform apply.

  • count: Creates multiple resource instances based on a count

    Why this is correct

    The count meta-argument allows a single resource block to provision multiple identical instances of a resource. By assigning an integer value to count, Terraform will create that exact number of resources, accessible via count.index. This is particularly useful for scaling out infrastructure components where each instance is largely homogeneous, such as multiple web servers or database replicas.

  • for_each: Creates multiple resource instances from a map or set

    Why this is correct

    The for_each meta-argument enables the creation of multiple resource instances based on the elements of a given map or set of strings. Unlike count, for_each assigns a unique key to each instance, making it suitable for managing heterogeneous or uniquely identifiable resources. This allows for more dynamic and flexible resource provisioning, where each instance's configuration might vary based on its corresponding map key or set element.

  • lifecycle: Controls resource lifecycle behaviors such as create_before_destroy

    Why this is correct

    The lifecycle meta-argument provides fine-grained control over how Terraform manages a resource's creation, update, and destruction phases. Options like create_before_destroy ensure a new resource is provisioned before the old one is terminated, minimizing downtime. Other settings, such as prevent_destroy or ignore_changes, help safeguard critical infrastructure or manage specific update scenarios.

  • count: Specifies hidden dependencies on other resources

    Why it's wrong here

    This statement incorrectly describes the purpose of the count meta-argument. count is designed solely for creating multiple instances of a resource based on a numerical value, not for managing resource dependencies. Explicitly declaring dependencies that Terraform cannot infer is the function of the depends_on meta-argument, which ensures correct operational sequencing.

  • lifecycle: Creates multiple resource instances based on a count

    Why it's wrong here

    This statement inaccurately attributes the function of creating multiple resource instances to the lifecycle meta-argument. The lifecycle block is dedicated to defining specific behaviors during a resource's provisioning and deprovisioning, such as preventing accidental destruction or controlling update strategies. Creating multiple resource instances is instead handled by the count or for_each meta-arguments.

About these practice questions

One of 428 original TF-004 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This TF-004 practice question is part of Courseiva's free HashiCorp certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the TF-004 exam.