nerdexam
HashiCorpHashiCorp

TA-002-P · Question #60

TA-002-P Question #60: Real Exam Question with Answer & Explanation

The correct answer is C: State file drift. The 'terraform refresh' command is used to reconcile the Terraform state file with the actual infrastructure deployed in the cloud or on-premises. It detects and updates the state file to reflect any changes made to resources outside of Terraform's management.

Use the Terraform CLI (terraform plan, apply, destroy, fmt, init, validate, workspace, import, taint, providers, output)

Question

What is terraform refresh intended to detect?

Options

  • ATerraform configuration code changes
  • BEmpty state files
  • CState file drift
  • DCorrupt state files

Explanation

The 'terraform refresh' command is used to reconcile the Terraform state file with the actual infrastructure deployed in the cloud or on-premises. It detects and updates the state file to reflect any changes made to resources outside of Terraform's management.

Common mistakes.

  • A. 'terraform plan' or 'terraform apply' detect configuration code changes by comparing the new configuration with the state file.
  • B. 'terraform refresh' operates on an existing state file and doesn't directly detect empty state files, though it might result in an empty state if no resources are found.
  • D. 'terraform refresh' does not validate the integrity of the state file's format; other commands or manual inspection would be needed for corrupt state files.

Concept tested. Terraform refresh command purpose

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

Topics

#terraform refresh#state file#state drift#CLI commands

Community Discussion

No community discussion yet for this question.

Full TA-002-P PracticeBrowse All TA-002-P Questions