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 →
- Know that plan and apply already refresh state by default.
- Use
terraform plan -refresh-onlyto review drift andterraform apply -refresh-onlyto accept it into state. - 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".
More on State Backends and Workspaces
Two engineers keep overwriting each other's changes because state is local. What's the fix?BeginnerSet up a production-grade S3 backend. What do you configure for locking?IntermediateHow do you harden the S3 bucket that holds Terraform state?IntermediateWho creates the state bucket itself, given Terraform needs it to exist before `init`?IntermediateA laptop apply and a CI apply start at the same time. What stops state corruption?IntermediateWhen are Terraform workspaces appropriate?Beginner