Courseiva
Implement and maintain statemediumMultiple SelectObjective-mapped

TF-004 Implement and maintain state Practice Question

Which TWO actions will cause Terraform to update the state file?

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 destroy

`terraform apply` and `terraform destroy` both modify the state file. `plan`, `validate`, and `fmt` do not make changes to the state.

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 fmt

    Why it's wrong here

    terraform fmt is purely a static code formatting tool. It parses HCL configuration files and rewrites them to a canonical format, improving readability and consistency across a project. This command operates solely on the `.tf` files within the working directory and never interacts with the Terraform state file, which tracks the deployed infrastructure's actual status.

  • terraform destroy

    Why this is correct

    terraform destroy is an imperative action that terminates and removes all resources currently managed by the Terraform configuration. Upon successful deletion of these resources from the cloud provider, Terraform meticulously updates the state file. This update marks those resources as removed, ensuring the state accurately reflects the infrastructure's current absence and preventing orphaned entries or inconsistencies with the real world.

  • terraform apply

    Why this is correct

    terraform apply is the primary command for provisioning and modifying infrastructure based on the defined configuration. It executes the changes outlined in a Terraform plan, interacting with cloud provider APIs to create, update, or delete resources as necessary. After successfully performing these operations, Terraform writes the updated resource attributes and relationships to the state file, reflecting the new desired and actual infrastructure configuration.

  • terraform validate

    Why it's wrong here

    terraform validate performs checks on the configuration files to ensure they are syntactically valid and internally consistent. It verifies expressions, argument types, and provider requirements without interacting with any remote services or the Terraform state file. This command is a static analysis tool, primarily used for early detection of configuration errors before planning or applying any infrastructure changes.

  • terraform plan

    Why it's wrong here

    terraform plan generates an execution plan, detailing what actions Terraform will take to achieve the desired state defined in the configuration. While it reads the current Terraform state to compare against the configuration and the real-world infrastructure, it is strictly a read-only operation concerning the state file itself. The plan output is merely a proposal; it never modifies the actual state or infrastructure.

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 →

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.