Courseiva
Read, generate and modify configurationhardMultiple ChoiceObjective-mapped

TF-004 Read, generate and modify configuration Practice Question

A Terraform configuration uses a module from the Terraform Registry. After updating the module version in the configuration, the operator runs 'terraform plan' but does not see the changes expected from the new version. What is the most likely cause?

⚠ Common exam trap

HashiCorp often tests the misconception that 'terraform plan' automatically fetches new module versions, when in fact 'terraform init' is required to update the module cache and lock file before planning.

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

The operator did not run 'terraform init' after changing the version.

When you change a module version in the configuration, Terraform must re-initialize the working directory to download the new version and update the dependency lock file (.terraform.lock.hcl). Running 'terraform plan' without first running 'terraform init' will use the previously cached module version, so the expected changes from the new version will not appear. 'terraform init' is the required command to fetch and lock the updated module source.

Answer analysis

Option-by-option breakdown

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

  • The operator did not run 'terraform get' to update modules.

    Why it's wrong here

    While `terraform get` was historically used to download modules, particularly for local or registry sources in older Terraform versions, it is largely superseded by `terraform init` in modern Terraform workflows. `terraform init` performs a comprehensive initialization, including downloading modules, providers, and setting up the backend. Therefore, simply running `terraform get` would not correctly update a module's version or fully prepare the working directory after a version change.

  • The operator did not run 'terraform init' after changing the version.

    Why this is correct

    When a module's version constraint is modified within the Terraform configuration, `terraform init` is the essential command to execute. This command re-evaluates all module requirements, downloads the newly specified module version into the `.terraform` directory, and updates the dependency lock file (`.terraform.lock.hcl`). Without running `init`, Terraform will continue to use the previously downloaded module version, leading to unexpected behavior or errors.

  • The operator did not run 'terraform refresh' to update state.

    Why it's wrong here

    `terraform refresh` is specifically designed to reconcile the Terraform state file with the actual attributes of existing remote infrastructure resources. It queries the cloud provider APIs to update the state file's representation of resource properties, ensuring accuracy before a plan or apply operation. This command does not interact with module source code, download new versions, or modify the local module cache, making it irrelevant for resolving module versioning issues.

  • The module version constraint is stored in the state file and must be updated.

    Why it's wrong here

    Module version constraints are explicitly defined within the Terraform configuration files, typically in the `source` and `version` arguments of a module block, not within the state file. The Terraform state file (`terraform.tfstate`) primarily records the mapping between configuration resources and their real-world counterparts, along with their current attributes and metadata. It does not store or manage module source code or its versioning requirements.

About these practice questions

Courseiva writes every TF-004 question from scratch — 428 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. 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.