nerdexam
HashiCorp

TA-002-P · Question #163

What does terraform refresh command do?

The correct answer is E. terraform refresh syncs the state file with the real world infrastructure. terraform refresh queries the provider APIs to reconcile the Terraform state file with the actual current state of real-world infrastructure, detecting drift without modifying infrastructure.

Implement and maintain state

Question

What does terraform refresh command do?

Options

  • AA. terraform refresh can be used to selectively update sections of the state file, using
  • Bterraform refresh command basically updates the configuration file with the current state
  • Cterraform refresh is use to change/modify the infrastructure based on the existing state
  • Dterraform refresh can be used to selectively update sections of the state file, using
  • Eterraform refresh syncs the state file with the real world infrastructure.

How the community answered

(18 responses)
  • D
    6% (1)
  • E
    94% (17)

Why each option

terraform refresh queries the provider APIs to reconcile the Terraform state file with the actual current state of real-world infrastructure, detecting drift without modifying infrastructure.

AA. terraform refresh can be used to selectively update sections of the state file, using

terraform refresh does not selectively update specific sections of the state file - it performs a full reconciliation of all tracked resources against real-world infrastructure in a single pass.

Bterraform refresh command basically updates the configuration file with the current state

terraform refresh updates the state file to match real-world infrastructure, not the configuration .tf files - configuration files are authored by users and are never modified by Terraform CLI commands.

Cterraform refresh is use to change/modify the infrastructure based on the existing state

terraform refresh does not change or modify infrastructure in any way - only terraform apply with an approved plan makes changes to real resources.

Dterraform refresh can be used to selectively update sections of the state file, using

This repeats the incorrect claim that terraform refresh selectively updates state sections, which contradicts its actual behavior of performing a complete state reconciliation.

Eterraform refresh syncs the state file with the real world infrastructure.Correct

The terraform refresh command contacts each provider API to read the real-world attributes of every resource tracked in the state file and updates the state to match what actually exists. It surfaces drift between the recorded state and actual infrastructure but never creates, modifies, or destroys any resources.

Concept tested: Terraform refresh state reconciliation with real-world infrastructure

Source: https://developer.hashicorp.com/terraform/cli/commands/refresh

Topics

#terraform refresh#state file#real world infrastructure#Terraform CLI

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice