Terraform-Associate-004 practice question 21 of 35
What is terraform plan -refresh-only intended to detect?
Full set: 360 questionsThe terraform plan -refresh-only command is specifically designed to detect "drift," which occurs when the real-world state of infrastructure diverges from the state recorded in Terraform's state file. This command instructs Terraform to query the cloud provider for the current status of all managed resources and compare that against the existing state file. The resulting plan will display any differences found, effectively highlighting changes made outside of Terraform's control. It intentionally ignores any changes made in the Terraform configuration files, focusing exclusively on reconciling the state with reality.
A. The -refresh-only flag explicitly tells Terraform to ignore any changes in the configuration code and focus only on the state.
B. While a corrupt state file would likely cause the command to fail, its primary purpose is not to act as a corruption checker.
D. This command operates on existing resources tracked in the state file; an empty state file implies no resources to refresh.
1. HashiCorp Terraform Documentation, "Command: plan", Refresh-Only Mode: "The -refresh-only flag is a convenient way to discover any drift between your configuration's state and the real-world infrastructure. This can be useful to detect any changes made outside of Terraform."
2. HashiCorp Learn, "Detect and Manage Drift with Terraform", Detect drift: "You can use the terraform plan or terraform apply commands with the -refresh-only flag to sync the Terraform state with the real-world infrastructure without making any changes. This lets you detect drift in your infrastructure."
3. HashiCorp Terraform Documentation, "Command: apply", Refresh-Only Mode: "The -refresh-only mode is useful when you've made manual changes to the remote objects and want to reconcile the Terraform state with those changes." This directly addresses the concept of drift (manual changes) and reconciliation.
Keep practicing
Take the free Terraform-Associate-004 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other Terraform-Associate-004 practice questions
- Question 1You should run terraform fnt to rewrite all Terraform configurations within the current w…
- Question 2Module variable assignments are inherited from the parent module and you do not need to e…
- Question 3terraform validate confirms thesyntaxof Terraform files.
- Question 4Using the terraform state rm command against a resource will destroy it.
- Question 5Variables declared within a module are accessible outside of the module.
- Question 6terraform init retrieves and caches the configuration for all remote modules.
