TF-004 Understand Terraform basics Practice Question
Which of the following are core concepts or behaviors of Terraform's execution model and state management? (Choose four.)
⚠ Common exam trap
HashiCorp often tests the misconception that refresh modifies infrastructure or that destroy only affects state, when in reality refresh is a read-only operation and destroy removes actual resources.
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
✓
Terraform uses a desired state model, where configuration defines the target state and Terraform determines the actions needed to reach it.
Terraform's execution model is fundamentally a desired state model: the configuration declares the target state, and Terraform computes the actions needed to reach it. The state file is the critical mapping between configuration and real-world resources, tracking metadata like dependencies and attributes. The plan phase produces a dry-run execution plan without making changes, while apply executes those changes and can be run directly without a saved plan file. These four behaviors—desired state, state file mapping, plan as dry-run, and apply as execution—are core to how Terraform operates.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Terraform uses a desired state model, where configuration defines the target state and Terraform determines the actions needed to reach it.
Why this is correct
Terraform operates on a desired state model, meaning users declare the intended final state of their infrastructure using configuration files. It then compares this desired state with the current actual state, as recorded in the state file, to identify any discrepancies. Based on this comparison, Terraform intelligently calculates the precise set of create, update, or delete actions required to transition the infrastructure from its current state to the desired configuration. This declarative approach simplifies infrastructure management by abstracting away the imperative steps.
- ✓
The Terraform state file maps real-world resources to your configuration, and keeps track of metadata such as resource dependencies and attributes.
Why this is correct
The Terraform state file is a crucial component that maintains a comprehensive mapping between the resources defined in your Terraform configuration and their corresponding real-world infrastructure objects. Beyond just identification, it stores essential metadata for each resource, including its current attributes, unique identifiers, and implicit dependencies on other resources. This persistent record allows Terraform to understand the current infrastructure landscape, track changes, and manage the lifecycle of resources effectively across multiple runs.
- ✓
Terraform plan produces an execution plan showing what actions will be taken to achieve the desired state, without making any changes.
Why this is correct
The `terraform plan` command is a vital safety mechanism that generates a detailed execution plan outlining all proposed infrastructure changes. This plan explicitly shows which resources will be created, updated, or destroyed to reconcile the current state with the desired configuration. Crucially, `terraform plan` is a read-only operation; it simulates the changes without actually modifying any real-world infrastructure, allowing users to review and approve the impact before applying.
- ✓
Terraform apply executes the changes proposed by the plan, and can be run with or without a prior plan being saved.
Why this is correct
The `terraform apply` command is responsible for executing the infrastructure changes determined by Terraform to reach the desired state. It can be invoked directly, in which case it implicitly generates a plan and then prompts for approval before applying. Alternatively, `terraform apply` can accept a previously saved plan file, ensuring that only the exact changes reviewed during the planning phase are implemented, which is common in automated CI/CD pipelines.
- ✗
Terraform refresh automatically updates the state file to match real-world infrastructure by modifying resources if differences are found.
Why it's wrong here
This statement is incorrect because `terraform refresh` (or the implicit refresh during `plan` and `apply`) only updates the state file to reflect the *current attributes* of real-world infrastructure resources. It performs a read-only operation against the cloud provider APIs to detect any out-of-band changes. However, `terraform refresh` itself *never modifies* the actual infrastructure resources; its sole purpose is to synchronize the state file with the current reality, not to change that reality.
- ✗
Terraform destroy removes all resources defined in the configuration from the state file only, without affecting the actual infrastructure.
Why it's wrong here
This statement is incorrect because `terraform destroy` is designed to *terminate and remove* all resources managed by the current Terraform configuration from the actual infrastructure provider. It does not merely remove entries from the state file; rather, it actively issues API calls to delete the corresponding real-world objects. Removing resources from the state file without affecting actual infrastructure would be a manual state manipulation, not the function of `terraform destroy`.
Go deeper
Related to this question
About these practice questions
This TF-004 question is part of Courseiva's 428-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
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.