refresh-only plan
A Terraform plan mode that reads the real resources and shows how they differ from state, without proposing to change them.
In more detail
Every normal plan also refreshes first, which is how drift appears. A refresh-only plan shows drift on its own so you can decide to revert or adopt it.
Examples
terraform plan -refresh-onlyIn Terraform: Run terraform plan -refresh-only to see what changed outside Terraform, then apply -refresh-only to accept those values into state. It replaced the older terraform refresh command, which updated state without showing you anything first.Related terms
- configuration drift — The slow, unrecorded way machines end up with different versions and settings from each other.
- terraform plan — The command that compares configuration, state and reality and prints the actions needed to make them match, without changing anything.
- Terraform state — Terraform's record, usually a JSON file called terraform.tfstate, mapping each resource in the configuration to the real object it created.
- refresh — Terraform asking each provider what the resources recorded in state really look like now, before it plans.
Taught in
- Continuous IaC Drift Detection & State Protection — Cloud Security & DevSecOps Engineering
- Detecting And Fixing Configuration Drift — Infrastructure as Code with Terraform
- Providers: How Terraform Reaches Every API — HashiCorp Terraform Associate (004) Exam Prep
- Versions, The Lock File And Provider Aliases — HashiCorp Terraform Associate (004) Exam Prep
- Write, Plan, Apply, And What Init Prepares — HashiCorp Terraform Associate (004) Exam Prep
- Reading A Plan, Saving It, Applying It — HashiCorp Terraform Associate (004) Exam Prep
- Validate, Format, Destroy, And The Flags That Bend A Plan — HashiCorp Terraform Associate (004) Exam Prep
- Remote State With The Backend Block — HashiCorp Terraform Associate (004) Exam Prep
- Drift: When Reality Stops Matching State — HashiCorp Terraform Associate (004) Exam Prep
- Trap Sprint: Twelve Answers That Are Almost True — HashiCorp Terraform Associate (004) Exam Prep
References
- Terraform: plan command, refresh-only mode
- terraform plan: planning modes
- Tutorial: use refresh-only mode