refresh
What is refresh?
refresh: Updates state to match real infrastructure without changing anything. Now folded into plan/apply by default. Refreshing in Terraform updates the state file to match the real infrastructure, without changing the infrastructure itself. It reads the current settings of every managed resource from the provider. Plans and applies now refresh automatically, so the separate terraform refresh command is deprecated. terraform plan -refresh-only shows what changed outside Terraform, and terraform apply -refresh-only accepts those changes into the state.
Frequently asked questions about refresh
What should you keep in mind with refresh?
This is how you deal with drift. If someone changed a setting by hand, a refresh-only plan shows it clearly. Then you decide whether to update your code to match reality, or run a normal apply to change the resource back. On large projects, refreshing takes time; -refresh=false skips it, but only use that when you are sure nothing changed.
What does an example of refresh look like?
terraform plan -refresh-only At a glance
| Category | Terraform |
|---|---|
| Explained by | Reinier de la Parra |
| Updated |