HashiCorp Certified: Terraform Associate — Question 187

What Terraform command always causes a state file to be updated with changes that might have been made outside of Terraform?

Answer options

Correct answer: A

Explanation

The command 'terraform plan -refresh-only' is specifically designed to refresh the state file with any changes that may have occurred outside of Terraform, making it the correct choice. The other options do not update the state file in this manner: 'terraform show -json' merely displays the state, 'terraform apply -lock-false' applies changes without locking, and 'terraform plan -target-state' focuses on specific resources without refreshing the entire state.