github.com/rstandt/terraform@v0.12.32-0.20230710220336-b1063613405c/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 * `-compact-warnings` - If Terraform produces any warnings that are not 33 accompanied by errors, show them in a more compact form that includes only 34 the summary messages. 35 36 * `-input=true` - Ask for input for variables if not directly set. 37 38 * `-lock=true` - Lock the state file when locking is supported. 39 40 * `-lock-timeout=0s` - Duration to retry a state lock. 41 42 * `-no-color` - If specified, output won't contain any color. 43 44 * `-parallelism=n` - Limit the number of concurrent operation as Terraform 45 [walks the graph](/docs/internals/graph.html#walking-the-graph). Defaults 46 to 10. 47 48 * `-state=path` - Path to read and write the state file to. Defaults to "terraform.tfstate". 49 Ignored when [remote state](/docs/state/remote.html) is used. 50 51 * `-state-out=path` - Path to write updated state file. By default, the 52 `-state` path will be used. Ignored when 53 [remote state](/docs/state/remote.html) is used. 54 55 * `-target=resource` - A [Resource 56 Address](/docs/internals/resource-addressing.html) to target. Operation will 57 be limited to this resource and its dependencies. This flag can be used 58 multiple times. 59 60 * `-var 'foo=bar'` - Set a variable in the Terraform configuration. This flag 61 can be set multiple times. Variable values are interpreted as 62 [HCL](/docs/configuration/syntax.html#HCL), so list and map values can be 63 specified via this flag. 64 65 * `-var-file=foo` - Set variables in the Terraform configuration from 66 a [variable file](/docs/configuration/variables.html#variable-files). If 67 a `terraform.tfvars` or any `.auto.tfvars` files are present in the current 68 directory, they will be automatically loaded. `terraform.tfvars` is loaded 69 first and the `.auto.tfvars` files after in alphabetical order. Any files 70 specified by `-var-file` override any values set automatically from files in 71 the working directory. This flag can be used multiple times.