nerdexam
HashiCorp

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.

Implement and maintain state

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)
  • A
    6% (1)
  • B
    6% (1)
  • C
    89% (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.

AYour cloud infrastructure

`terraform refresh` explicitly does *not* modify your cloud infrastructure; it only reads the current state from the cloud.

BYour Terraform plan

`terraform refresh` does not generate or modify a Terraform plan; it focuses solely on updating the state file.

CYour state fileCorrect

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`.

DYour Terraform configuration

`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

#terraform refresh#state file#state management#Terraform CLI

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice