Interview Prep/Terraform/State Backends and Workspaces

What is `terraform refresh` and what replaced it?

BeginnerScenarioState Backends and Workspaces
Answer

Situation read → An old doc says to run refresh before plan.

What I'd do →

  1. Know that plan and apply already refresh state by default.
  2. Use terraform plan -refresh-only to review drift and terraform apply -refresh-only to accept it into state.
  3. Avoid the standalone terraform refresh, which writes state without showing a diff.

Why → Refresh-only mode adds a review step, whereas the bare command can silently write bad data into state, for example after a credentials mistake.

Interview tip → "refresh-only mode is the safe version".

All Terraform questions Roadmap: Terraform in production

More on State Backends and Workspaces