When warnings appear in isolation (not accompanied by an error) it's reasonable to want to defer resolving them for a while because they are not actually blocking immediate work. However, our warning messages tend to be long by default in order to include all of the necessary context to understand the implications of the warning, and that can make them overwhelming when combined with other output. As a compromise, this adds a new CLI option -compact-warnings which is supported for all the main operation commands and which uses a more compact format to print out warnings as long as they aren't also accompanied by errors. The default remains unchanged except that the threshold for consolidating warning messages is reduced to one so that we'll now only show one of each distinct warning summary. Full warning messages are always shown if there's at least one error included in the diagnostic set too, because in that case the warning message could contain additional context to help understand the error.
3.0 KiB
layout, page_title, sidebar_current, description
| layout | page_title | sidebar_current | description |
|---|---|---|---|
| docs | Command: refresh | docs-commands-refresh | 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. |
Command: refresh
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.
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:
-
-backup=path- Path to the backup file. Defaults to-state-outwith the ".backup" extension. Disabled by setting to "-". -
-compact-warnings- If Terraform produces any warnings that are not accompanied by errors, show them in a more compact form that includes only the summary messages. -
-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. -
-parallelism=n- Limit the number of concurrent operation as Terraform walks the graph. Defaults to 10. -
-state=path- Path to read and write the state file to. Defaults to "terraform.tfstate". Ignored when remote state is used. -
-state-out=path- Path to write updated state file. By default, the-statepath will be used. Ignored when remote state is used. -
-target=resource- A Resource Address to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times. -
-var 'foo=bar'- Set a variable in the Terraform configuration. This flag can be set multiple times. Variable values are interpreted as HCL, so list and map values can be specified via this flag. -
-var-file=foo- Set variables in the Terraform configuration from a variable file. If aterraform.tfvarsor any.auto.tfvarsfiles are present in the current directory, they will be automatically loaded.terraform.tfvarsis loaded first and the.auto.tfvarsfiles after in alphabetical order. Any files specified by-var-fileoverride any values set automatically from files in the working directory. This flag can be used multiple times.