terraform/website/source/docs/commands/refresh.html.markdown

64 lines
2.5 KiB
Markdown
Raw Normal View History

2014-07-24 18:02:10 +02:00
---
layout: "docs"
page_title: "Command: refresh"
sidebar_current: "docs-commands-refresh"
2014-10-22 05:21:56 +02:00
description: |-
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.
2014-07-24 18:02:10 +02:00
---
# Command: refresh
The `terraform refresh` command is used to reconcile the state Terraform
knows about (via its state file) with the real-world infrastructure.
2014-10-16 18:16:52 +02:00
This can be used to detect any drift from the last-known state, and to
2014-07-24 18:02:10 +02:00
update the state file.
This does not modify infrastructure, but does modify the state file.
If the state is changed, this may cause changes to occur during the next
plan or apply.
## Usage
Usage: `terraform refresh [options] [dir]`
By default, `refresh` requires no flags and looks in the current directory
for the configuration and state file to refresh.
The command-line flags are all optional. The list of available flags are:
2014-07-28 05:40:18 +02:00
* `-backup=path` - Path to the backup file. Defaults to `-state-out` with
the ".backup" extension. Disabled by setting to "-".
2014-07-28 05:40:18 +02:00
2014-07-24 18:02:10 +02:00
* `-no-color` - Disables output with coloring
2017-04-04 19:48:59 +02:00
* `-input=true` - Ask for input for variables if not directly set.
* `-lock=true` - Lock the state file when locking is supported.
* `-lock-timeout=0s` - Duration to retry a state lock.
* `-no-color` - If specified, output won't contain any color.
2014-07-24 18:02:10 +02:00
* `-state=path` - Path to read and write the state file to. Defaults to "terraform.tfstate".
Ignored when [remote state](/docs/state/remote.html) is used.
2014-07-24 18:02:10 +02:00
* `-state-out=path` - Path to write updated state file. By default, the
`-state` path will be used. Ignored when
[remote state](/docs/state/remote.html) is used.
2014-07-24 18:02:10 +02:00
2015-04-01 01:48:54 +02:00
* `-target=resource` - A [Resource
Address](/docs/internals/resource-addressing.html) to target. Operation will
be limited to this resource and its dependencies. This flag can be used
multiple times.
2015-03-27 23:24:15 +01:00
2016-07-12 00:37:51 +02:00
* `-var 'foo=bar'` - Set a variable in the Terraform configuration. This flag
can be set multiple times. Variable values are interpreted as
[HCL](/docs/configuration/syntax.html#HCL), so list and map values can be
specified via this flag.
2014-07-24 18:02:10 +02:00
* `-var-file=foo` - Set variables in the Terraform configuration from
2016-07-12 00:37:51 +02:00
a [variable file](/docs/configuration/variables.html#variable-files). If
"terraform.tfvars" is present, it will be automatically loaded first. Any
files specified by `-var-file` override any values in a "terraform.tfvars".
This flag can be used multiple times.