github.com/hugorut/terraform@v1.1.3/website/docs/cli/commands/refresh.mdx (about) 1 --- 2 page_title: 'Command: refresh' 3 description: |- 4 The `terraform refresh` command reads the current settings from all managed 5 remote objects and updates the Terraform state to match. 6 --- 7 8 # Command: refresh 9 10 > **Hands-on:** Try the [Use Refresh-Only Mode to Sync Terraform State](https://learn.hashicorp.com/tutorials/terraform/refresh) tutorial on HashiCorp Learn. 11 12 The `terraform refresh` command reads the current settings from all managed 13 remote objects and updates the Terraform state to match. 14 15 ~> _Warning:_ This command is deprecated, because its default behavior is 16 unsafe if you have misconfigured credentials for any of your providers. 17 See below for more information and recommended alternatives. 18 19 This won't modify your real remote objects, but it will modify the 20 [Terraform state](/language/state). 21 22 You shouldn't typically need to use this command, because Terraform 23 automatically performs the same refreshing actions as a part of creating 24 a plan in both the 25 [`terraform plan`](/cli/commands/plan) 26 and 27 [`terraform apply`](/cli/commands/apply) 28 commands. This command is here primarily for backward compatibility, but 29 we don't recommend using it because it provides no opportunity to review 30 the effects of the operation before updating the state. 31 32 ## Usage 33 34 Usage: `terraform refresh [options]` 35 36 This command is effectively an alias for the following command: 37 38 ``` 39 terraform apply -refresh-only -auto-approve 40 ``` 41 42 Consequently, it supports all of the same options as 43 [`terraform apply`](/cli/commands/apply) except that it does not accept a saved 44 plan file, it doesn't allow selecting a planning mode other than "refresh only", 45 and `-auto-approve` is always enabled. 46 47 Automatically applying the effect of a refresh is risky, because if you have 48 misconfigured credentials for one or more providers then the provider may 49 be misled into thinking that all of the managed objects have been deleted, 50 and thus remove all of the tracked objects without any confirmation prompt. 51 52 Instead, we recommend using the following command in order to get the same 53 effect but with the opportunity to review the changes that Terraform has 54 detected before committing them to the state: 55 56 ``` 57 terraform apply -refresh-only 58 ``` 59 60 This alternative command will present an interactive prompt for you to confirm 61 the detected changes. 62 63 The `-refresh-only` option for `terraform plan` and `terraform apply` was 64 introduced in Terraform v0.15.4. For prior versions you must use 65 `terraform refresh` directly if you need this behavior, while taking into 66 account the warnings above. Wherever possible, avoid using `terraform refresh` 67 explicitly and instead rely on Terraform's behavior of automatically refreshing 68 existing objects as part of creating a normal plan.