Skip to main content

Command: refresh

The terraform refresh command is deprecated in favor of terraform apply -refresh-only. The refresh command will be removed in a future version of Terraform.
The terraform refresh command reads the current settings from all managed remote objects and updates the Terraform state to match.

Usage

terraform refresh [options]
This command updates the state file of your infrastructure with metadata that matches the physical resources they are tracking. This will not modify your infrastructure, but it can modify your state file to update metadata. This metadata might cause new changes to occur when you generate a plan or call apply next.
This command is effectively an alias for terraform apply -refresh-only -auto-approve. Use terraform apply -refresh-only for the non-deprecated workflow.

Options

  • -compact-warnings - If Terraform produces any warnings that are not accompanied by errors, show them in a more compact form that includes only the summary messages.
  • -input=true - Ask for input for variables if not directly set.
  • -lock=false - Don’t hold a state lock during the operation. This is dangerous if others might concurrently run commands against the same workspace.
  • -lock-timeout=DURATION - Duration to retry a state lock. Default is 0s.
  • -no-color - If specified, output won’t contain any color.
  • -parallelism=n - Limit the number of concurrent operations. Defaults to 10.
  • -target=resource - A Resource Address to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.
  • -var 'NAME=VALUE' - Set a value for one of the input variables in the root module of the configuration. Use this option multiple times to set more than one variable.
  • -var-file=FILENAME - Set values for potentially many input variables declared in the root module of the configuration, using definitions from a “tfvars” file. Use this option multiple times to include values from more than one file.
For configurations using the local backend only, terraform refresh also accepts the legacy options -state, -state-out, and -backup.

Alternative: apply -refresh-only

The recommended replacement for terraform refresh is:
terraform apply -refresh-only
This provides better visibility and control over the refresh operation with a plan preview before applying changes to state.

Build docs developers (and LLMs) love