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