HashiCorp Terraform Associate (004) exam dumps

HashiCorp Terraform Associate (004) practice question 49 of 223

Terraform Associate 004. Associate level, HashiCorp. Free question with the correct answer and a full explanation.

HashiCorp Terraform Associate (004) Question 49

Single answer3 Core Terraform workflow

A platform team stores its Terraform configuration in Git and uses a remote backend for state. A developer updates a module version in the root configuration and wants to review the exact infrastructure changes before applying them in production. The team also wants the reviewed plan to be the same one that gets applied later in the deployment step. Which approach best satisfies this requirement in the core Terraform workflow?

  1. A

    Run terraform validate to confirm the configuration, then run terraform apply during deployment because Terraform will recalculate the same changes.

  2. B

    Run terraform plan -out=prod.tfplan after initializing, review the proposed changes, and later run terraform apply prod.tfplan in the deployment step.

  3. C

    Run terraform fmt and commit the formatted files, then run terraform apply in production because formatting ensures the plan will not change.

  4. D

    Run terraform refresh to update the state file, review the refreshed state, and then run terraform apply without creating a saved plan file.

Show answer and explanation

Correct answer: B

Explanation

The best answer is to generate and save a plan with terraform plan -out=prod.tfplan, review that plan, and later apply the same file with terraform apply prod.tfplan. This is a core Terraform workflow practice when teams want stronger control between planning and applying, especially in CI/CD pipelines or production approval processes. terraform validate and terraform fmt are useful workflow commands, but they do not replace planning. A key distinction is that terraform apply without a saved plan file creates a fresh plan at execution time, so it may not exactly match what was previously reviewed. HashiCorp documentation for the Terraform workflow and command references describes using saved plan files to ensure the reviewed execution plan is the one actually applied.

  • A. Incorrect.

    terraform validate checks whether the configuration is syntactically valid and internally consistent, but it does not produce an execution plan to review or guarantee that a later apply uses the exact same set of actions. If you run terraform apply without a saved plan file, Terraform generates a new plan at apply time, which could differ if the environment or state changed.

  • B. Correct.

    This is correct. In the standard Terraform workflow, you run terraform init as needed, then terraform plan -out=... to create a saved execution plan. That plan can be reviewed and then applied later with terraform apply <planfile>. Using a saved plan file ensures the apply step executes the reviewed plan rather than recalculating a new one at deployment time.

  • C. Incorrect.

    terraform fmt only rewrites configuration files into Terraform's canonical style. It improves readability and consistency but has no effect on whether infrastructure changes are reviewed or whether the exact reviewed plan is applied later.

  • D. Incorrect.

    terraform refresh is not the right solution here. Refresh-related behavior is about reconciling state with real infrastructure, not about preserving a reviewed execution plan for later application. Reviewing state is also not the same as reviewing proposed changes. Applying without a saved plan would cause Terraform to create a new plan at apply time.

Timed practice exam

Take a HashiCorp Terraform Associate (004) practice test under exam conditions

70 questions in 60 minutes, drawn from this bank, with a score report and a per-question review when you finish.

Start timed exam