github.com/hs0210/hashicorp-terraform@v0.11.12-beta1/website/docs/commands/refresh.html.markdown (about) 1 --- 2 layout: "docs" 3 page_title: "Command: refresh" 4 sidebar_current: "docs-commands-refresh" 5 description: |- 6 The `terraform refresh` command is used to reconcile the state Terraform knows about (via its state file) with the real-world infrastructure. This can be used to detect any drift from the last-known state, and to update the state file. 7 --- 8 9 # Command: refresh 10 11 The `terraform refresh` command is used to reconcile the state Terraform 12 knows about (via its state file) with the real-world infrastructure. 13 This can be used to detect any drift from the last-known state, and to 14 update the state file. 15 16 This does not modify infrastructure, but does modify the state file. 17 If the state is changed, this may cause changes to occur during the next 18 plan or apply. 19 20 ## Usage 21 22 Usage: `terraform refresh [options] [dir]` 23 24 By default, `refresh` requires no flags and looks in the current directory 25 for the configuration and state file to refresh. 26 27 The command-line flags are all optional. The list of available flags are: 28 29 * `-backup=path` - Path to the backup file. Defaults to `-state-out` with 30 the ".backup" extension. Disabled by setting to "-". 31 32 * `-input=true` - Ask for input for variables if not directly set. 33 34 * `-lock=true` - Lock the state file when locking is supported. 35 36 * `-lock-timeout=0s` - Duration to retry a state lock. 37 38 * `-no-color` - If specified, output won't contain any color. 39 40 * `-state=path` - Path to read and write the state file to. Defaults to "terraform.tfstate". 41 Ignored when [remote state](/docs/state/remote.html) is used. 42 43 * `-state-out=path` - Path to write updated state file. By default, the 44 `-state` path will be used. Ignored when 45 [remote state](/docs/state/remote.html) is used. 46 47 * `-target=resource` - A [Resource 48 Address](/docs/internals/resource-addressing.html) to target. Operation will 49 be limited to this resource and its dependencies. This flag can be used 50 multiple times. 51 52 * `-var 'foo=bar'` - Set a variable in the Terraform configuration. This flag 53 can be set multiple times. Variable values are interpreted as 54 [HCL](/docs/configuration/syntax.html#HCL), so list and map values can be 55 specified via this flag. 56 57 * `-var-file=foo` - Set variables in the Terraform configuration from 58 a [variable file](/docs/configuration/variables.html#variable-files). If 59 a `terraform.tfvars` or any `.auto.tfvars` files are present in the current 60 directory, they will be automatically loaded. `terraform.tfvars` is loaded 61 first and the `.auto.tfvars` files after in alphabetical order. Any files 62 specified by `-var-file` override any values set automatically from files in 63 the working directory. This flag can be used multiple times.