TA-002-P · Question #343
What does terraform refresh modify?
The correct answer is C. Your state file. The terraform refresh command updates the Terraform state file to reflect the current actual state of resources in the cloud provider without modifying the infrastructure itself. It compares the existing state with the real-world infrastructure and records any detected drift.
Question
What does terraform refresh modify?
Options
- AYour cloud infrastructure
- BYour Terraform plan
- CYour state file
- DYour Terraform configuration
How the community answered
(18 responses)- A6% (1)
- B6% (1)
- C89% (16)
Why each option
The `terraform refresh` command updates the Terraform state file to reflect the current actual state of resources in the cloud provider without modifying the infrastructure itself. It compares the existing state with the real-world infrastructure and records any detected drift.
`terraform refresh` explicitly does *not* modify your cloud infrastructure; it only reads the current state from the cloud.
`terraform refresh` does not generate or modify a Terraform plan; it focuses solely on updating the state file.
The `terraform refresh` command directly modifies the Terraform state file by reconciling it with the actual infrastructure. It queries the cloud provider for the current attributes of all managed resources and updates the state file to reflect any changes or drift that have occurred since the last `apply`.
`terraform refresh` does not modify your Terraform configuration files (HCL code); it only interacts with the state file and the cloud provider.
Concept tested: Terraform refresh command purpose
Source: https://developer.hashicorp.com/terraform/cli/commands/refresh
Topics
Community Discussion
No community discussion yet for this question.