TERRAFORM-ASSOCIATE-003 practice question 14 of 30

[Navigate Terraform State and Backends] What Terraform command always causes a state file to be updated with changes that might have been made outside of Terraform?

Full set: 226 questions
Answer options
A: Terraform plan –refresh-only Correct answer
B: Terraform show –json
C: Terraform apply –lock-false
D: Terraform plan target-state
Correct Answer:
A. Terraform plan –refresh-only
Explanation

terraform plan -refresh-only reads the current real-world infrastructure, compares it to the objects recorded in the state, and then rewrites the local/remote state file with any detected drift, even if the configuration itself proposes no changes. Because the sole purpose of –refresh-only is to synchronize state with out-of-band modifications, invoking the flag always updates the state file. No other listed command guarantees that a write to state will occur purely to record external changes.

Why Incorrect

B. terraform show –json only prints the current state or plan in JSON; it never writes to the state file.
C. terraform apply –lock=false may write state only if the plan contains changes; –lock=false merely skips state locking and does not force a refresh.
D. terraform plan target-state is not a valid Terraform CLI syntax; therefore, it cannot update state.

References

1. HashiCorp Terraform CLI

“plan Command –refresh-only Option

” https://developer.hashicorp.com/terraform/cli/commands/plan#refresh-only

¶2–3 (accessed 2025-09-24).

2. HashiCorp Terraform CLI

“Command: show

” https://developer.hashicorp.com/terraform/cli/commands/show

¶1 (read-only nature).

3. HashiCorp Terraform CLI

“Command: apply

” https://developer.hashicorp.com/terraform/cli/commands/apply

¶4

option –lock

note on state writes only after successful changes.

Scroll to Top