Commit 0e48f586 authored by Dylan Staley's avatar Dylan Staley
Browse files

Revert "migrate docs to mdx"

This reverts commit 3cb12b5a.
parent 3cb12b5a
Showing with 255 additions and 245 deletions
+255 -245
--- ---
page_title: Authentication - Terraform CLI layout: "docs"
description: >- page_title: "Authentication - Terraform CLI"
Documentation about the login and logout commands that help automate getting description: "Documentation about the login and logout commands that help automate getting an API token for your Terraform Cloud account."
an API token for your Terraform Cloud account.
sidebar_title: Authentication
--- ---
# CLI Authentication # CLI Authentication
> **Hands-on:** Try the [Authenticate the CLI with Terraform Cloud](https://learn.hashicorp.com/tutorials/terraform/cloud-login?in=terraform/cloud&utm_source=WEBSITE&utm_medium=WEB_IO&utm_offer=ARTICLE_PAGE&utm_content=DOCS) tutorial on HashiCorp Learn. > **Hands-on:** Try the [Authenticate the CLI with Terraform Cloud](https://learn.hashicorp.com/tutorials/terraform/cloud-login?in=terraform/cloud&utm_source=WEBSITE&utm_medium=WEB_IO&utm_offer=ARTICLE_PAGE&utm_content=DOCS) tutorial on HashiCorp Learn.
[Terraform Cloud](/cloud-docs/) and [Terraform Cloud](/docs/cloud/index.html) and
[Terraform Enterprise](/enterprise/) are platforms that perform [Terraform Enterprise](/docs/enterprise/index.html) are platforms that perform
Terraform runs to provision infrastructure, offering a collaboration-focused Terraform runs to provision infrastructure, offering a collaboration-focused
environment that makes it easier for teams to use Terraform together. (For environment that makes it easier for teams to use Terraform together. (For
expediency, the content below refers to both products as "Terraform Cloud.") expediency, the content below refers to both products as "Terraform Cloud.")
Terraform CLI integrates with Terraform Cloud in several ways — it can be a Terraform CLI integrates with Terraform Cloud in several ways — it can be a
front-end for [CLI-driven runs](/cloud-docs/run/cli) in Terraform Cloud, front-end for [CLI-driven runs](/docs/cloud/run/cli.html) in Terraform Cloud,
and can also use Terraform Cloud as a state backend and a private module and can also use Terraform Cloud as a state backend and a private module
registry. All of these integrations require you to authenticate Terraform CLI registry. All of these integrations require you to authenticate Terraform CLI
with your Terraform Cloud account. with your Terraform Cloud account.
...@@ -28,5 +26,5 @@ Terraform Cloud user account. ...@@ -28,5 +26,5 @@ Terraform Cloud user account.
For details, see: For details, see:
- [The `terraform login` command](/cli/commands/login) - [The `terraform login` command](/docs/cli/commands/login.html)
- [The `terraform logout` command](/cli/commands/logout) - [The `terraform logout` command](/docs/cli/commands/logout.html)
--- ---
page_title: Writing and Modifying Code - Terraform CLI layout: "docs"
description: >- page_title: "Writing and Modifying Code - Terraform CLI"
Learn commands that help validate, format, and upgrade code written in the description: "Learn commands that help validate, format, and upgrade code written in the Terraform Configuration Language."
Terraform Configuration Language.
sidebar_title: Writing and Modifying Code
--- ---
# Writing and Modifying Terraform Code # Writing and Modifying Terraform Code
The [Terraform language](/language/) is Terraform's primary The [Terraform language](/docs/language/index.html) is Terraform's primary
user interface, and all of Terraform's workflows rely on configurations written user interface, and all of Terraform's workflows rely on configurations written
in the Terraform language. in the Terraform language.
...@@ -16,17 +14,18 @@ Terraform CLI includes several commands to make Terraform code more convenient ...@@ -16,17 +14,18 @@ Terraform CLI includes several commands to make Terraform code more convenient
to work with. Integrating these commands into your editing workflow can to work with. Integrating these commands into your editing workflow can
potentially save you time and effort. potentially save you time and effort.
- [The `terraform console` command](/cli/commands/console) starts an - [The `terraform console` command](/docs/cli/commands/console.html) starts an
interactive shell for evaluating Terraform interactive shell for evaluating Terraform
[expressions](/language/expressions/), which can be a faster way [expressions](/docs/language/expressions/index.html), which can be a faster way
to verify that a particular resource argument results in the value you expect. to verify that a particular resource argument results in the value you expect.
- [The `terraform fmt` command](/cli/commands/fmt) rewrites Terraform
- [The `terraform fmt` command](/docs/cli/commands/fmt.html) rewrites Terraform
configuration files to a canonical format and style, so you don't have to configuration files to a canonical format and style, so you don't have to
waste time making minor adjustments for readability and consistency. It works waste time making minor adjustments for readability and consistency. It works
well as a pre-commit hook in your version control system. well as a pre-commit hook in your version control system.
- [The `terraform validate` command](/cli/commands/validate) validates the - [The `terraform validate` command](/docs/cli/commands/validate.html) validates the
syntax and arguments of the Terraform configuration files in a directory, syntax and arguments of the Terraform configuration files in a directory,
including argument and attribute names and types for resources and modules. including argument and attribute names and types for resources and modules.
The `plan` and `apply` commands automatically validate a configuration before The `plan` and `apply` commands automatically validate a configuration before
...@@ -34,12 +33,12 @@ potentially save you time and effort. ...@@ -34,12 +33,12 @@ potentially save you time and effort.
workflow, but it can be very useful as a pre-commit hook or as part of a workflow, but it can be very useful as a pre-commit hook or as part of a
continuous integration pipeline. continuous integration pipeline.
- [The `0.13upgrade` command](/cli/commands/0.13upgrade) and - [The `0.13upgrade` command](/docs/cli/commands/0.13upgrade.html) and
[the `0.12upgrade` command](/cli/commands/0.12upgrade) can automatically [the `0.12upgrade` command](/docs/cli/commands/0.12upgrade.html) can automatically
modify the configuration files in a Terraform module to help deal with major modify the configuration files in a Terraform module to help deal with major
syntax changes that occurred in the 0.13 and 0.12 releases of Terraform. Both syntax changes that occurred in the 0.13 and 0.12 releases of Terraform. Both
of these commands are only available in the Terraform version they are of these commands are only available in the Terraform version they are
associated with, and you are expected to upgrade older code to be compatible associated with, and you are expected to upgrade older code to be compatible
with 0.12 before attempting to make it compatible with 0.13. For more detailed with 0.12 before attempting to make it compatible with 0.13. For more detailed
information about updating code for new Terraform versions, see the [upgrade information about updating code for new Terraform versions, see the [upgrade
guides](/upgrade-guides/) in the Terraform language docs. guides](/upgrade-guides/index.html) in the Terraform language docs.
--- ---
page_title: 'Command: 0.12upgrade' layout: "docs"
description: >- page_title: "Command: 0.12upgrade"
The 0.12upgrade subcommand automatically rewrites existing configurations for sidebar_current: "docs-commands-012upgrade"
Terraform 0.12 compatibility. description: |-
The 0.12upgrade subcommand automatically rewrites existing configurations for Terraform 0.12 compatibility.
--- ---
# Command: 0.12upgrade # Command: 0.12upgrade
...@@ -11,7 +12,7 @@ The `terraform 0.12upgrade` command applies several automatic upgrade rules to ...@@ -11,7 +12,7 @@ The `terraform 0.12upgrade` command applies several automatic upgrade rules to
help prepare a module that was written for Terraform v0.11 to be used help prepare a module that was written for Terraform v0.11 to be used
with Terraform v0.12. with Terraform v0.12.
-> **This command is available only in Terraform v0.12 releases.** For more information, see [the Terraform v0.12 upgrade guide](/upgrade-guides/0-12). -> **This command is available only in Terraform v0.12 releases.** For more information, see [the Terraform v0.12 upgrade guide](https://www.terraform.io/upgrade-guides/0-12.html).
## Usage ## Usage
...@@ -70,13 +71,13 @@ the change. ...@@ -70,13 +71,13 @@ the change.
Once upgraded the configuration will no longer be compatible with Terraform Once upgraded the configuration will no longer be compatible with Terraform
v0.11 and earlier. When upgrading a shared module that is called from multiple v0.11 and earlier. When upgrading a shared module that is called from multiple
configurations, you may need to configurations, you may need to
[fix existing configurations to a previous version](/language/modules/syntax#version) [fix existing configurations to a previous version](/docs/language/modules/syntax.html#version)
to allow for a gradual upgrade. If the module is published via to allow for a gradual upgrade. If the module is published via
[a Terraform registry](/registry/), assign a new _major_ version number [a Terraform registry](/docs/registry/), assign a new _major_ version number
to the upgraded module source to represent the fact that this is a breaking to the upgraded module source to represent the fact that this is a breaking
change for v0.11 callers. If a module is installed directly from a version change for v0.11 callers. If a module is installed directly from a version
control system such as Git, control system such as Git,
[use specific revisions](/language/modules/sources#selecting-a-revision) [use specific revisions](https://www.terraform.io/docs/language/modules/sources.html#selecting-a-revision)
to control which version is used by which caller. to control which version is used by which caller.
The command-line options are all optional. The available options are: The command-line options are all optional. The available options are:
...@@ -106,9 +107,9 @@ On Mac OS X, the `find` included with the system does not support the `-printf` ...@@ -106,9 +107,9 @@ On Mac OS X, the `find` included with the system does not support the `-printf`
``` ```
brew install findutils brew install findutils
``` ```
Once installed, run the above command line using `gfind` instead of `find`. Once installed, run the above command line using `gfind` instead of `find`.
Note that the above includes the `-yes` option to override the interactive Note that the above includes the `-yes` option to override the interactive
prompt, so be sure you have a clean work tree before running it. prompt, so be sure you have a clean work tree before running it.
......
--- ---
page_title: 'Command: 0.13upgrade' layout: "docs"
description: >- page_title: "Command: 0.13upgrade"
The 0.13upgrade subcommand updates existing configurations to use the new sidebar_current: "docs-commands-013upgrade"
provider source features from Terraform 0.13. description: |-
The 0.13upgrade subcommand updates existing configurations to use the new provider source features from Terraform 0.13.
--- ---
# Command: 0.13upgrade # Command: 0.13upgrade
...@@ -11,7 +12,7 @@ The `terraform 0.13upgrade` command updates existing configuration to add an ...@@ -11,7 +12,7 @@ The `terraform 0.13upgrade` command updates existing configuration to add an
explicit `source` attribute for each provider used in a given module. The explicit `source` attribute for each provider used in a given module. The
provider source settings are stored in a `required_providers` block. provider source settings are stored in a `required_providers` block.
-> **This command is available only in Terraform v0.13 releases.** For more information, see [the Terraform v0.13 upgrade guide](/upgrade-guides/0-13). -> **This command is available only in Terraform v0.13 releases.** For more information, see [the Terraform v0.13 upgrade guide](https://www.terraform.io/upgrade-guides/0-13.html).
## Usage ## Usage
...@@ -22,7 +23,7 @@ providers are in use for a module, detect the source address for those ...@@ -22,7 +23,7 @@ providers are in use for a module, detect the source address for those
providers where possible, and record this information in a providers where possible, and record this information in a
[`required_providers` block][required-providers]. [`required_providers` block][required-providers].
[required-providers]: /language/providers/requirements [required-providers]: /docs/language/providers/requirements.html
~> Note: the command ignores `.tf.json` files and override files in the module. ~> Note: the command ignores `.tf.json` files and override files in the module.
......
--- ---
page_title: 'Command: apply' layout: "docs"
description: >- page_title: "Command: apply"
The terraform apply command executes the actions proposed in a Terraform plan sidebar_current: "docs-commands-apply"
to create, update, or destroy infrastructure. description: "The terraform apply command executes the actions proposed in a Terraform plan to create, update, or destroy infrastructure."
--- ---
# Command: apply # Command: apply
...@@ -33,15 +33,15 @@ you pass it the filename of a previously-saved plan file. ...@@ -33,15 +33,15 @@ you pass it the filename of a previously-saved plan file.
### Automatic Plan Mode ### Automatic Plan Mode
In the default case, with no saved plan file, `terraform apply` creates its own In the default case, with no saved plan file, `terraform apply` creates its own
plan of action, in the same way that [`terraform plan`](/cli/commands/plan) would. plan of action, in the same way that [`terraform plan`](./plan.html) would.
Terraform will propose the plan to you and prompt you to approve it before Terraform will propose the plan to you and prompt you to approve it before
taking the described actions, unless you waive that prompt by using the taking the described actions, unless you waive that prompt by using the
`-auto-approve` option. `-auto-approve` option.
When performing its own plan, `terraform apply` supports all of the same When performing its own plan, `terraform apply` supports all of the same
[planning modes](/cli/commands/plan#planning-modes) and [planning modes](./plan.html#planning-modes) and
[planning options](/cli/commands/plan#planning-options) that `terraform plan` would [planning options](./plan.html#planning-options) that `terraform plan` would
accept, so you can customize how Terraform will create the plan. accept, so you can customize how Terraform will create the plan.
### Saved Plan Mode ### Saved Plan Mode
...@@ -49,7 +49,7 @@ accept, so you can customize how Terraform will create the plan. ...@@ -49,7 +49,7 @@ accept, so you can customize how Terraform will create the plan.
If you pass the filename of a previously-saved plan file, `terraform apply` If you pass the filename of a previously-saved plan file, `terraform apply`
performs exactly the steps specified by that plan file. It does not prompt for performs exactly the steps specified by that plan file. It does not prompt for
approval; if you want to inspect a plan file before applying it, you can use approval; if you want to inspect a plan file before applying it, you can use
[`terraform show`](/cli/commands/show). [`terraform show`](./show.html).
When using a saved plan, none of the planning modes or planning options linked When using a saved plan, none of the planning modes or planning options linked
above are supported; these options only affect Terraform's decisions about which above are supported; these options only affect Terraform's decisions about which
...@@ -61,8 +61,8 @@ decisions. ...@@ -61,8 +61,8 @@ decisions.
When run without a saved plan file, `terraform apply` supports all of `terraform When run without a saved plan file, `terraform apply` supports all of `terraform
plan`'s planning modes and planning options. For details, see: plan`'s planning modes and planning options. For details, see:
* [Planning Modes](/cli/commands/plan#planning-modes) - [Planning Modes](./plan.html#planning-modes)
* [Planning Options](/cli/commands/plan#planning-options) - [Planning Options](./plan.html#planning-options)
### Apply Options ### Apply Options
...@@ -70,7 +70,7 @@ The following options allow you to change various details about how the ...@@ -70,7 +70,7 @@ The following options allow you to change various details about how the
apply command executes and reports on the apply operation. If you are running apply command executes and reports on the apply operation. If you are running
`terraform apply` _without_ a previously-saved plan file, these options are `terraform apply` _without_ a previously-saved plan file, these options are
_in addition to_ the planning modes and planning options described for _in addition to_ the planning modes and planning options described for
[`terraform plan`](/cli/commands/plan). [`terraform plan`](./plan.html).
* `-auto-approve` - Skips interactive approval of plan before applying. This * `-auto-approve` - Skips interactive approval of plan before applying. This
option is ignored when you pass a previously-saved plan file, because option is ignored when you pass a previously-saved plan file, because
...@@ -95,11 +95,11 @@ _in addition to_ the planning modes and planning options described for ...@@ -95,11 +95,11 @@ _in addition to_ the planning modes and planning options described for
variable values to continue. To enable this flag, you must also either enable variable values to continue. To enable this flag, you must also either enable
the `-auto-approve` flag or specify a previously-saved plan. the `-auto-approve` flag or specify a previously-saved plan.
[machine-readable-ui]: /internals/machine-readable-ui [machine-readable-ui]: /docs/internals/machine-readable-ui.html
* `-lock=false` - Don't hold a state lock during the operation. This is * `-lock=false` - Don't hold a state lock during the operation. This is
dangerous if others might concurrently run commands against the same dangerous if others might concurrently run commands against the same
workspace. workspace.
* `-lock-timeout=DURATION` - Unless locking is disabled with `-lock=false`, * `-lock-timeout=DURATION` - Unless locking is disabled with `-lock=false`,
instructs Terraform to retry acquiring a lock for a period of time before instructs Terraform to retry acquiring a lock for a period of time before
...@@ -111,13 +111,13 @@ _in addition to_ the planning modes and planning options described for ...@@ -111,13 +111,13 @@ _in addition to_ the planning modes and planning options described for
rendered by a system that cannot interpret terminal formatting. rendered by a system that cannot interpret terminal formatting.
* `-parallelism=n` - Limit the number of concurrent operation as Terraform * `-parallelism=n` - Limit the number of concurrent operation as Terraform
[walks the graph](/internals/graph#walking-the-graph). Defaults to [walks the graph](/docs/internals/graph.html#walking-the-graph). Defaults to
10\. 10.
For configurations using For configurations using
[the `local` backend](/language/settings/backends/local) only, [the `local` backend](/docs/language/settings/backends/local.html) only,
`terraform apply` also accepts the legacy options `terraform apply` also accepts the legacy options
[`-state`, `-state-out`, and `-backup`](/language/settings/backends/local#command-line-arguments). [`-state`, `-state-out`, and `-backup`](/docs/language/settings/backends/local.html#command-line-arguments).
## Passing a Different Configuration Directory ## Passing a Different Configuration Directory
...@@ -127,7 +127,7 @@ that directory as the root module instead of the current working directory. ...@@ -127,7 +127,7 @@ that directory as the root module instead of the current working directory.
That usage was deprecated in Terraform v0.14 and removed in Terraform v0.15. That usage was deprecated in Terraform v0.14 and removed in Terraform v0.15.
If your workflow relies on overriding the root module directory, use If your workflow relies on overriding the root module directory, use
[the `-chdir` global option](/cli/commands/#switching-working-directory-with-chdir) [the `-chdir` global option](./#switching-working-directory-with-chdir)
instead, which works across all commands and makes Terraform consistently look instead, which works across all commands and makes Terraform consistently look
in the given directory for all files it would normally read or write in the in the given directory for all files it would normally read or write in the
current working directory. current working directory.
...@@ -135,6 +135,6 @@ current working directory. ...@@ -135,6 +135,6 @@ current working directory.
If your previous use of this legacy pattern was also relying on Terraform If your previous use of this legacy pattern was also relying on Terraform
writing the `.terraform` subdirectory into the current working directory even writing the `.terraform` subdirectory into the current working directory even
though the root module directory was overridden, use though the root module directory was overridden, use
[the `TF_DATA_DIR` environment variable](/cli/config/environment-variables#tf_data_dir) [the `TF_DATA_DIR` environment variable](/docs/cli/config/environment-variables.html#tf_data_dir)
to direct Terraform to write the `.terraform` directory to a location other to direct Terraform to write the `.terraform` directory to a location other
than the current working directory. than the current working directory.
--- ---
page_title: 'Command: console' layout: "docs"
description: >- page_title: "Command: console"
The terraform console command provides an interactive console for evaluating sidebar_current: "docs-commands-console"
expressions. description: "The terraform console command provides an interactive console for
evaluating expressions."
--- ---
# Command: console # Command: console
The `terraform console` command provides an interactive console for The `terraform console` command provides an interactive console for
evaluating [expressions](/language/expressions/). evaluating [expressions](/docs/language/expressions/index.html).
## Usage ## Usage
Usage: `terraform console [options]` Usage: `terraform console [options]`
This command provides an interactive command-line console for evaluating and This command provides an interactive command-line console for evaluating and
experimenting with [expressions](/language/expressions/). experimenting with [expressions](/docs/language/expressions/index.html).
This is useful for testing interpolations before using them in configurations, This is useful for testing interpolations before using them in configurations,
and for interacting with any values currently saved in and for interacting with any values currently saved in
[state](/language/state/). [state](/docs/language/state/index.html).
If the current state is empty or has not yet been created, the console can be If the current state is empty or has not yet been created, the console can be
used to experiment with the expression syntax and used to experiment with the expression syntax and
[built-in functions](/language/functions/). [built-in functions](/docs/language/functions/index.html).
You can close the console with the `exit` command or by pressing Control-C You can close the console with the `exit` command or by pressing Control-C
or Control-D. or Control-D.
For configurations using For configurations using
[the `local` backend](/language/settings/backends/local) only, [the `local` backend](/docs/language/settings/backends/local.html) only,
`terraform console` accepts the legacy command line option `terraform console` accepts the legacy command line option
[`-state`](/language/settings/backends/local#command-line-arguments). [`-state`](/docs/language/settings/backends/local.html#command-line-arguments).
## Scripting ## Scripting
...@@ -51,7 +52,7 @@ tolist([ ...@@ -51,7 +52,7 @@ tolist([
## Remote State ## Remote State
If [remote state](/language/state/remote) is used by the current backend, If [remote state](/docs/language/state/remote.html) is used by the current backend,
Terraform will read the state for the current workspace from the backend Terraform will read the state for the current workspace from the backend
before evaluating any expressions. before evaluating any expressions.
......
--- ---
page_title: 'Command: destroy' layout: "docs"
description: >- page_title: "Command: destroy"
The terraform destroy command destroys all objects managed by a Terraform sidebar_current: "docs-commands-destroy"
configuration. description: "The terraform destroy command destroys all objects managed by a Terraform configuration."
--- ---
# Command: destroy # Command: destroy
...@@ -27,7 +27,7 @@ terraform apply -destroy ...@@ -27,7 +27,7 @@ terraform apply -destroy
``` ```
For that reason, this command accepts most of the options that For that reason, this command accepts most of the options that
[`terraform apply`](/cli/commands/apply) accepts, although it does [`terraform apply`](./apply.html) accepts, although it does
not accept a plan file argument and forces the selection of the "destroy" not accept a plan file argument and forces the selection of the "destroy"
planning mode. planning mode.
...@@ -38,7 +38,7 @@ destroying would be, by running the following command: ...@@ -38,7 +38,7 @@ destroying would be, by running the following command:
terraform plan -destroy terraform plan -destroy
``` ```
This will run [`terraform plan`](/cli/commands/plan) in _destroy_ mode, showing This will run [`terraform plan`](./plan.html) in _destroy_ mode, showing
you the proposed destroy changes without executing them. you the proposed destroy changes without executing them.
-> **Note:** The `-destroy` option to `terraform apply` exists only in -> **Note:** The `-destroy` option to `terraform apply` exists only in
......
---
layout: "docs"
page_title: "Command: env"
sidebar_current: "docs-commands-envcmd"
description: "The terraform env command is a deprecated form of the terraform workspace command."
---
# Command: env
The `terraform env` command is deprecated.
[The `terraform workspace` command](/docs/cli/commands/workspace/index.html)
should be used instead.
---
page_title: 'Command: env'
description: >-
The terraform env command is a deprecated form of the terraform workspace
command.
---
# Command: env
The `terraform env` command is deprecated.
[The `terraform workspace` command](/cli/commands/workspace/)
should be used instead.
--- ---
page_title: 'Command: fmt' layout: "docs"
description: >- page_title: "Command: fmt"
The terraform fmt command rewrites configuration files to a canonical format sidebar_current: "docs-commands-fmt"
and style. description: "The terraform fmt command rewrites configuration files to a canonical format and style."
--- ---
# Command: fmt # Command: fmt
The `terraform fmt` command is used to rewrite Terraform configuration files The `terraform fmt` command is used to rewrite Terraform configuration files
to a canonical format and style. This command applies a subset of to a canonical format and style. This command applies a subset of
the [Terraform language style conventions](/language/syntax/style), the [Terraform language style conventions](/docs/language/syntax/style.html),
along with other minor adjustments for readability. along with other minor adjustments for readability.
Other Terraform commands that generate Terraform configuration will produce Other Terraform commands that generate Terraform configuration will produce
...@@ -58,5 +58,5 @@ The command-line flags are all optional. The list of available flags are: ...@@ -58,5 +58,5 @@ The command-line flags are all optional. The list of available flags are:
* `-write=false` - Don't overwrite the input files. (This is implied by `-check` or when the input is STDIN.) * `-write=false` - Don't overwrite the input files. (This is implied by `-check` or when the input is STDIN.)
* `-diff` - Display diffs of formatting changes * `-diff` - Display diffs of formatting changes
* `-check` - Check if the input is formatted. Exit status will be 0 if * `-check` - Check if the input is formatted. Exit status will be 0 if
all input is properly formatted and non-zero otherwise. all input is properly formatted and non-zero otherwise.
* `-recursive` - Also process files in subdirectories. By default, only the given directory (or current directory) is processed. * `-recursive` - Also process files in subdirectories. By default, only the given directory (or current directory) is processed.
--- ---
page_title: 'Command: force-unlock' layout: "docs"
description: >- page_title: "Command: force-unlock"
The terraform force-unlock command unlocks the state for a configuration. It sidebar_current: "docs-commands-force-unlock"
does not modify your infrastructure. description: "The terraform force-unlock command unlocks the state for a configuration. It does not modify your infrastructure."
--- ---
# Command: force-unlock # Command: force-unlock
...@@ -27,4 +27,4 @@ process. ...@@ -27,4 +27,4 @@ process.
Options: Options:
* `-force` - Don't ask for input for unlock confirmation. * `-force` - Don't ask for input for unlock confirmation.
--- ---
page_title: 'Command: get' layout: "docs"
description: The terraform get command downloads and updates modules. page_title: "Command: get"
sidebar_current: "docs-commands-get"
description: "The terraform get command downloads and updates modules."
--- ---
# Command: get # Command: get
The `terraform get` command is used to download and update The `terraform get` command is used to download and update
[modules](/language/modules/develop/) mentioned in the root module. [modules](/docs/language/modules/develop/index.html) mentioned in the root module.
## Usage ## Usage
...@@ -19,6 +21,6 @@ repository. ...@@ -19,6 +21,6 @@ repository.
The `get` command supports the following option: The `get` command supports the following option:
* `-update` - If specified, modules that are already downloaded will be * `-update` - If specified, modules that are already downloaded will be
checked for updates and the updates will be downloaded if present. checked for updates and the updates will be downloaded if present.
* `-no-color` - Disable text coloring in the output. * `-no-color` - Disable text coloring in the output.
--- ---
page_title: 'Command: graph' layout: "docs"
description: >- page_title: "Command: graph"
The terraform graph command generates a visual representation of a sidebar_current: "docs-commands-graph"
configuration or execution plan that you can use to generate charts. description: "The terraform graph command generates a visual representation of a configuration or execution plan that you can use to generate charts."
--- ---
# Command: graph # Command: graph
...@@ -12,6 +12,7 @@ representation of either a configuration or execution plan. ...@@ -12,6 +12,7 @@ representation of either a configuration or execution plan.
The output is in the DOT format, which can be used by The output is in the DOT format, which can be used by
[GraphViz](http://www.graphviz.org) to generate charts. [GraphViz](http://www.graphviz.org) to generate charts.
## Usage ## Usage
Usage: `terraform graph [options]` Usage: `terraform graph [options]`
...@@ -32,16 +33,16 @@ argument. ...@@ -32,16 +33,16 @@ argument.
Options: Options:
* `-plan=tfplan` - Render graph using the specified plan file instead of the * `-plan=tfplan` - Render graph using the specified plan file instead of the
configuration in the current directory. configuration in the current directory.
* `-draw-cycles` - Highlight any cycles in the graph with colored edges. * `-draw-cycles` - Highlight any cycles in the graph with colored edges.
This helps when diagnosing cycle errors. This helps when diagnosing cycle errors.
* `-type=plan` - Type of graph to output. Can be: `plan`, `plan-destroy`, `apply`, * `-type=plan` - Type of graph to output. Can be: `plan`, `plan-destroy`, `apply`,
`validate`, `input`, `refresh`. `validate`, `input`, `refresh`.
* `-module-depth=n` - (deprecated) In prior versions of Terraform, specified the * `-module-depth=n` - (deprecated) In prior versions of Terraform, specified the
depth of modules to show in the output. depth of modules to show in the output.
## Generating Images ## Generating Images
...@@ -54,4 +55,4 @@ $ terraform graph | dot -Tsvg > graph.svg ...@@ -54,4 +55,4 @@ $ terraform graph | dot -Tsvg > graph.svg
``` ```
Here is an example graph output: Here is an example graph output:
![Graph Example](/img/docs/graph-example.png) ![Graph Example](docs/graph-example.png)
--- ---
page_title: 'Command: import' layout: "docs"
description: The terraform import command brings existing resources into Terraform state. page_title: "Command: import"
sidebar_current: "docs-commands-import"
description: "The terraform import command brings existing resources into Terraform state."
--- ---
# Command: import # Command: import
...@@ -8,7 +10,7 @@ description: The terraform import command brings existing resources into Terrafo ...@@ -8,7 +10,7 @@ description: The terraform import command brings existing resources into Terrafo
> **Hands-on:** Try the [Import Terraform Configuration](https://learn.hashicorp.com/tutorials/terraform/state-import?in=terraform/state&utm_source=WEBSITE&utm_medium=WEB_IO&utm_offer=ARTICLE_PAGE&utm_content=DOCS) tutorial on HashiCorp Learn. > **Hands-on:** Try the [Import Terraform Configuration](https://learn.hashicorp.com/tutorials/terraform/state-import?in=terraform/state&utm_source=WEBSITE&utm_medium=WEB_IO&utm_offer=ARTICLE_PAGE&utm_content=DOCS) tutorial on HashiCorp Learn.
The `terraform import` command is used to The `terraform import` command is used to
[import existing resources](/cli/import/) [import existing resources](/docs/cli/import/index.html)
into Terraform. into Terraform.
## Usage ## Usage
...@@ -18,7 +20,7 @@ Usage: `terraform import [options] ADDRESS ID` ...@@ -18,7 +20,7 @@ Usage: `terraform import [options] ADDRESS ID`
Import will find the existing resource from ID and import it into your Terraform Import will find the existing resource from ID and import it into your Terraform
state at the given ADDRESS. state at the given ADDRESS.
ADDRESS must be a valid [resource address](/cli/state/resource-addressing). ADDRESS must be a valid [resource address](/docs/cli/state/resource-addressing.html).
Because any resource address is valid, the import command can import resources Because any resource address is valid, the import command can import resources
into modules as well as directly into the root of your state. into modules as well as directly into the root of your state.
...@@ -34,7 +36,7 @@ itself having created all objects. If you import existing objects into Terraform ...@@ -34,7 +36,7 @@ itself having created all objects. If you import existing objects into Terraform
be careful to import each remote object to only one Terraform resource address. be careful to import each remote object to only one Terraform resource address.
If you import the same object multiple times, Terraform may exhibit unwanted If you import the same object multiple times, Terraform may exhibit unwanted
behavior. For more information on this assumption, see behavior. For more information on this assumption, see
[the State section](/language/state/). [the State section](/docs/language/state/index.html).
The command-line flags are all optional. The list of available flags are: The command-line flags are all optional. The list of available flags are:
...@@ -46,29 +48,29 @@ The command-line flags are all optional. The list of available flags are: ...@@ -46,29 +48,29 @@ The command-line flags are all optional. The list of available flags are:
* `-input=true` - Whether to ask for input for provider configuration. * `-input=true` - Whether to ask for input for provider configuration.
* `-lock=false` - Don't hold a state lock during the operation. This is * `-lock=false` - Don't hold a state lock during the operation. This is
dangerous if others might concurrently run commands against the same dangerous if others might concurrently run commands against the same
workspace. workspace.
* `-lock-timeout=0s` - Duration to retry a state lock. * `-lock-timeout=0s` - Duration to retry a state lock.
* `-no-color` - If specified, output won't contain any color. * `-no-color` - If specified, output won't contain any color.
* `-parallelism=n` - Limit the number of concurrent operation as Terraform * `-parallelism=n` - Limit the number of concurrent operation as Terraform
[walks the graph](/internals/graph#walking-the-graph). Defaults [walks the graph](/docs/internals/graph.html#walking-the-graph). Defaults
to 10. to 10.
* `-provider=provider` - **Deprecated** Override the provider configuration to * `-provider=provider` - **Deprecated** Override the provider configuration to
use when importing the object. By default, Terraform uses the provider specified use when importing the object. By default, Terraform uses the provider specified
in the configuration for the target resource, and that is the best behavior in most cases. in the configuration for the target resource, and that is the best behavior in most cases.
* `-var 'foo=bar'` - Set a variable in the Terraform configuration. This flag * `-var 'foo=bar'` - Set a variable in the Terraform configuration. This flag
can be set multiple times. Variable values are interpreted as can be set multiple times. Variable values are interpreted as
[literal expressions](/language/expressions/types) in the [literal expressions](/docs/language/expressions/types.html) in the
Terraform language, so list and map values can be specified via this flag. Terraform language, so list and map values can be specified via this flag.
This is only useful with the `-config` flag. This is only useful with the `-config` flag.
* `-var-file=foo` - Set variables in the Terraform configuration from * `-var-file=foo` - Set variables in the Terraform configuration from
a [variable file](/language/values/variables#variable-definitions-tfvars-files). If a [variable file](/docs/language/values/variables.html#variable-definitions-tfvars-files). If
a `terraform.tfvars` or any `.auto.tfvars` files are present in the current a `terraform.tfvars` or any `.auto.tfvars` files are present in the current
directory, they will be automatically loaded. `terraform.tfvars` is loaded directory, they will be automatically loaded. `terraform.tfvars` is loaded
first and the `.auto.tfvars` files after in alphabetical order. Any files first and the `.auto.tfvars` files after in alphabetical order. Any files
...@@ -77,15 +79,15 @@ The command-line flags are all optional. The list of available flags are: ...@@ -77,15 +79,15 @@ The command-line flags are all optional. The list of available flags are:
useful with the `-config` flag. useful with the `-config` flag.
For configurations using For configurations using
[the `remote` backend](/language/settings/backends/remote) [the `remote` backend](/docs/language/settings/backends/remote.html)
only, `terraform import` only, `terraform import`
also accepts the option also accepts the option
[`-ignore-remote-version`](/language/settings/backends/remote#command-line-arguments). [`-ignore-remote-version`](/docs/language/settings/backends/remote.html#command-line-arguments).
For configurations using For configurations using
[the `local` backend](/language/settings/backends/local) only, [the `local` backend](/docs/language/settings/backends/local.html) only,
`terraform import` also accepts the legacy options `terraform import` also accepts the legacy options
[`-state`, `-state-out`, and `-backup`](/language/settings/backends/local#command-line-arguments). [`-state`, `-state-out`, and `-backup`](/docs/language/settings/backends/local.html#command-line-arguments).
## Provider Configuration ## Provider Configuration
...@@ -133,7 +135,7 @@ $ terraform import module.foo.aws_instance.bar i-abcd1234 ...@@ -133,7 +135,7 @@ $ terraform import module.foo.aws_instance.bar i-abcd1234
## Example: Import into Resource configured with count ## Example: Import into Resource configured with count
The example below will import an AWS instance into the first instance of the `aws_instance` resource named `baz` configured with The example below will import an AWS instance into the first instance of the `aws_instance` resource named `baz` configured with
[`count`](/language/meta-arguments/count): [`count`](/docs/language/meta-arguments/count.html):
```shell ```shell
$ terraform import 'aws_instance.baz[0]' i-abcd1234 $ terraform import 'aws_instance.baz[0]' i-abcd1234
...@@ -142,7 +144,7 @@ $ terraform import 'aws_instance.baz[0]' i-abcd1234 ...@@ -142,7 +144,7 @@ $ terraform import 'aws_instance.baz[0]' i-abcd1234
## Example: Import into Resource configured with for_each ## Example: Import into Resource configured with for_each
The example below will import an AWS instance into the `"example"` instance of the `aws_instance` resource named `baz` configured with The example below will import an AWS instance into the `"example"` instance of the `aws_instance` resource named `baz` configured with
[`for_each`](/language/meta-arguments/for_each): [`for_each`](/docs/language/meta-arguments/for_each.html):
Linux, Mac OS, and UNIX: Linux, Mac OS, and UNIX:
......
--- ---
page_title: Basic CLI Features layout: "docs"
description: An introduction to the terraform command and its available subcommands. page_title: "Basic CLI Features"
sidebar_current: "docs-commands"
description: "An introduction to the terraform command and its available subcommands."
--- ---
# Basic CLI Features # Basic CLI Features
...@@ -15,8 +17,8 @@ of this page. ...@@ -15,8 +17,8 @@ of this page.
We refer to the `terraform` command line tool as "Terraform CLI" elsewhere We refer to the `terraform` command line tool as "Terraform CLI" elsewhere
in the documentation. This terminology is often used to distinguish it from in the documentation. This terminology is often used to distinguish it from
other components you might use in the Terraform product family, such as other components you might use in the Terraform product family, such as
[Terraform Cloud](/cloud-docs/) or [Terraform Cloud](/docs/cloud/) or
the various [Terraform providers](/language/providers/), which the various [Terraform providers](/docs/language/providers/index.html), which
are developed and released separately from Terraform CLI. are developed and released separately from Terraform CLI.
To view a list of the commands available in your current Terraform version, To view a list of the commands available in your current Terraform version,
...@@ -98,7 +100,7 @@ will be read or written in the given directory instead. ...@@ -98,7 +100,7 @@ will be read or written in the given directory instead.
There are two exceptions where Terraform will use the original working directory There are two exceptions where Terraform will use the original working directory
even when you specify `-chdir=...`: even when you specify `-chdir=...`:
* Settings in the [CLI Configuration](/cli/config/config-file) are not for a specific * Settings in the [CLI Configuration](/docs/cli/config/config-file.html) are not for a specific
subcommand and Terraform processes them before acting on the `-chdir` subcommand and Terraform processes them before acting on the `-chdir`
option. option.
...@@ -151,7 +153,7 @@ Checkpoint itself can be entirely disabled for all HashiCorp products by ...@@ -151,7 +153,7 @@ Checkpoint itself can be entirely disabled for all HashiCorp products by
setting the environment variable `CHECKPOINT_DISABLE` to any non-empty value. setting the environment variable `CHECKPOINT_DISABLE` to any non-empty value.
Alternatively, settings in Alternatively, settings in
[the CLI configuration file](/cli/config/config-file) can be used to [the CLI configuration file](/docs/cli/config/config-file.html) can be used to
disable checkpoint features. The following checkpoint-related settings are disable checkpoint features. The following checkpoint-related settings are
supported in this file: supported in this file:
......
--- ---
page_title: 'Command: init' layout: "docs"
description: >- page_title: "Command: init"
The terraform init command initializes a working directory containing sidebar_current: "docs-commands-init"
configuration files and installs plugins for required providers. description: "The terraform init command initializes a working directory containing configuration files and installs plugins for required providers."
--- ---
# Command: init # Command: init
...@@ -74,7 +74,7 @@ activating credentials) before running `terraform init`. ...@@ -74,7 +74,7 @@ activating credentials) before running `terraform init`.
## Backend Initialization ## Backend Initialization
During init, the root configuration directory is consulted for During init, the root configuration directory is consulted for
[backend configuration](/language/settings/backends/configuration) and the chosen backend [backend configuration](/docs/language/settings/backends/configuration.html) and the chosen backend
is initialized using the given configuration settings. is initialized using the given configuration settings.
Re-running init with an already-initialized backend will update the working Re-running init with an already-initialized backend will update the working
...@@ -96,14 +96,14 @@ when the working directory was already previously initialized for a particular ...@@ -96,14 +96,14 @@ when the working directory was already previously initialized for a particular
backend. backend.
The `-backend-config=...` option can be used for The `-backend-config=...` option can be used for
[partial backend configuration](/language/settings/backends/configuration#partial-configuration), [partial backend configuration](/docs/language/settings/backends/configuration.html#partial-configuration),
in situations where the backend settings are dynamic or sensitive and so cannot in situations where the backend settings are dynamic or sensitive and so cannot
be statically specified in the configuration file. be statically specified in the configuration file.
## Child Module Installation ## Child Module Installation
During init, the configuration is searched for `module` blocks, and the source During init, the configuration is searched for `module` blocks, and the source
code for referenced [modules](/language/modules/develop/) is retrieved from the locations code for referenced [modules](/docs/language/modules/develop/index.html) is retrieved from the locations
given in their `source` arguments. given in their `source` arguments.
Re-running init with modules already installed will install the sources for Re-running init with modules already installed will install the sources for
...@@ -128,13 +128,13 @@ third-party provider registry, `terraform init` will automatically find, ...@@ -128,13 +128,13 @@ third-party provider registry, `terraform init` will automatically find,
download, and install the necessary provider plugins. If you cannot or do not download, and install the necessary provider plugins. If you cannot or do not
wish to install providers from their origin registries, you can customize how wish to install providers from their origin registries, you can customize how
Terraform installs providers using Terraform installs providers using
[the provider installation settings in the CLI configuration](/cli/config/config-file#provider-installation). [the provider installation settings in the CLI configuration](/docs/cli/config/config-file.html#provider-installation).
For more information about specifying which providers are required for each For more information about specifying which providers are required for each
of your modules, see [Provider Requirements](/language/providers/requirements). of your modules, see [Provider Requirements](/docs/language/providers/requirements.html).
After successful installation, Terraform writes information about the selected After successful installation, Terraform writes information about the selected
providers to [the dependency lock file](/language/dependency-lock). providers to [the dependency lock file](/docs/language/dependency-lock.html).
You should commit this file to your version control system to ensure that You should commit this file to your version control system to ensure that
when you run `terraform init` again in future Terraform will select exactly when you run `terraform init` again in future Terraform will select exactly
the same provider versions. Use the `-upgrade` option if you want Terraform the same provider versions. Use the `-upgrade` option if you want Terraform
...@@ -142,31 +142,31 @@ to ignore the dependency lock file and consider installing newer versions. ...@@ -142,31 +142,31 @@ to ignore the dependency lock file and consider installing newer versions.
You can modify `terraform init`'s plugin behavior with the following options: You can modify `terraform init`'s plugin behavior with the following options:
* `-upgrade` Upgrade all previously-selected plugins to the newest version - `-upgrade` Upgrade all previously-selected plugins to the newest version
that complies with the configuration's version constraints. This will that complies with the configuration's version constraints. This will
cause Terraform to ignore any selections recorded in the dependency lock cause Terraform to ignore any selections recorded in the dependency lock
file, and to take the newest available version matching the configured file, and to take the newest available version matching the configured
version constraints. version constraints.
* `-get-plugins=false` — Skip plugin installation. - `-get-plugins=false` — Skip plugin installation.
-> Note: Since Terraform 0.13, this option has been superseded by the -> Note: Since Terraform 0.13, this option has been superseded by the
[`provider_installation`](/cli/config/config-file#provider-installation) and [`provider_installation`](/docs/cli/config/config-file.html#provider-installation) and
[`plugin_cache_dir`](/cli/config/config-file#plugin_cache_dir) settings. [`plugin_cache_dir`](/docs/cli/config/config-file.html#plugin_cache_dir) settings.
It should not be used in Terraform versions 0.13+, and this option It should not be used in Terraform versions 0.13+, and this option
was removed in Terraform 0.15. was removed in Terraform 0.15.
* `-plugin-dir=PATH` — Force plugin installation to read plugins _only_ from - `-plugin-dir=PATH` — Force plugin installation to read plugins _only_ from
the specified directory, as if it had been configured as a `filesystem_mirror` the specified directory, as if it had been configured as a `filesystem_mirror`
in the CLI configuration. If you intend to routinely use a particular in the CLI configuration. If you intend to routinely use a particular
filesystem mirror then we recommend filesystem mirror then we recommend
[configuring Terraform's installation methods globally](/cli/config/config-file#provider-installation). [configuring Terraform's installation methods globally](/docs/cli/config/config-file.html#provider-installation).
You can use `-plugin-dir` as a one-time override for exceptional situations, You can use `-plugin-dir` as a one-time override for exceptional situations,
such as if you are testing a local build of a provider plugin you are such as if you are testing a local build of a provider plugin you are
currently developing. currently developing.
* `-lockfile=MODE` Set a dependency lockfile mode. - `-lockfile=MODE` Set a dependency lockfile mode.
The valid values for the lockfile mode are as follows: The valid values for the lockfile mode are as follows:
* readonly: suppress the lockfile changes, but verify checksums against the - readonly: suppress the lockfile changes, but verify checksums against the
information already recorded. It conflicts with the `-upgrade` flag. If you information already recorded. It conflicts with the `-upgrade` flag. If you
update the lockfile with third-party dependency management tools, it would be update the lockfile with third-party dependency management tools, it would be
useful to control when it changes explicitly. useful to control when it changes explicitly.
...@@ -192,7 +192,7 @@ that directory as the root module instead of the current working directory. ...@@ -192,7 +192,7 @@ that directory as the root module instead of the current working directory.
That usage is still supported in Terraform v0.14, but is now deprecated and we That usage is still supported in Terraform v0.14, but is now deprecated and we
plan to remove it in Terraform v0.15. If your workflow relies on overriding plan to remove it in Terraform v0.15. If your workflow relies on overriding
the root module directory, use the root module directory, use
[the `-chdir` global option](/cli/commands/#switching-working-directory-with-chdir) [the `-chdir` global option](./#switching-working-directory-with-chdir)
instead, which works across all commands and makes Terraform consistently look instead, which works across all commands and makes Terraform consistently look
in the given directory for all files it would normally read or write in the in the given directory for all files it would normally read or write in the
current working directory. current working directory.
...@@ -200,6 +200,6 @@ current working directory. ...@@ -200,6 +200,6 @@ current working directory.
If your previous use of this legacy pattern was also relying on Terraform If your previous use of this legacy pattern was also relying on Terraform
writing the `.terraform` subdirectory into the current working directory even writing the `.terraform` subdirectory into the current working directory even
though the root module directory was overridden, use though the root module directory was overridden, use
[the `TF_DATA_DIR` environment variable](/cli/config/environment-variables#tf_data_dir) [the `TF_DATA_DIR` environment variable](/docs/cli/config/environment-variables.html#tf_data_dir)
to direct Terraform to write the `.terraform` directory to a location other to direct Terraform to write the `.terraform` directory to a location other
than the current working directory. than the current working directory.
--- ---
page_title: 'Command: login' layout: "docs"
description: >- page_title: "Command: login"
The terraform login command can be used to automatically obtain and save an sidebar_current: "docs-commands-login"
API token for Terraform Cloud, Terraform Enterprise, or any other host that description: |-
offers Terraform services. The terraform login command can be used to automatically obtain and save an API token for Terraform Cloud, Terraform Enterprise, or any other host that offers Terraform services.
--- ---
# Command: login # Command: login
...@@ -15,7 +15,7 @@ API token for Terraform Cloud, Terraform Enterprise, or any other host that offe ...@@ -15,7 +15,7 @@ API token for Terraform Cloud, Terraform Enterprise, or any other host that offe
where it is possible to launch a web browser on the same host where Terraform where it is possible to launch a web browser on the same host where Terraform
is running. If you are running Terraform in an unattended automation scenario, is running. If you are running Terraform in an unattended automation scenario,
you can you can
[configure credentials manually in the CLI configuration](/cli/config/config-file#credentials). [configure credentials manually in the CLI configuration](https://www.terraform.io/docs/cli/config/config-file.html#credentials).
## Usage ## Usage
...@@ -34,12 +34,12 @@ not as desired. ...@@ -34,12 +34,12 @@ not as desired.
If you don't wish to store your API token in the default location, you can If you don't wish to store your API token in the default location, you can
optionally configure a optionally configure a
[credentials helper program](/cli/config/config-file#credentials-helpers) which knows [credentials helper program](/docs/cli/config/config-file.html#credentials-helpers) which knows
how to store and later retrieve credentials in some other system, such as how to store and later retrieve credentials in some other system, such as
your organization's existing secrets management system. your organization's existing secrets management system.
## Login Server Support ## Login Server Support
The `terraform login` command works with any server supporting the The `terraform login` command works with any server supporting the
[login protocol](/internals/login-protocol), including Terraform Cloud [login protocol](/docs/internals/login-protocol.html), including Terraform Cloud
and Terraform Enterprise. and Terraform Enterprise.
--- ---
page_title: 'Command: logout' layout: "docs"
description: >- page_title: "Command: logout"
The terraform logout command is used to remove credentials stored by terraform sidebar_current: "docs-commands-logout"
login. description: |-
The terraform logout command is used to remove credentials stored by terraform login.
--- ---
# Command: logout # Command: logout
...@@ -25,5 +26,5 @@ the remote server, so it will remain valid until manually revoked. ...@@ -25,5 +26,5 @@ the remote server, so it will remain valid until manually revoked.
By default, Terraform will remove the token stored in plain text in a local CLI By default, Terraform will remove the token stored in plain text in a local CLI
configuration file called `credentials.tfrc.json`. If you have configured a configuration file called `credentials.tfrc.json`. If you have configured a
[credentials helper program](/cli/config/config-file#credentials-helpers), Terraform [credentials helper program](/docs/cli/config/config-file.html#credentials-helpers), Terraform
will use the helper's `forget` command to remove it. will use the helper's `forget` command to remove it.
--- ---
page_title: 'Command: output' layout: "docs"
description: >- page_title: "Command: output"
The `terraform output` command is used to extract the value of an output sidebar_current: "docs-commands-output"
variable from the state file. description: |-
The `terraform output` command is used to extract the value of an output variable from the state file.
--- ---
# Command: output # Command: output
...@@ -21,20 +22,20 @@ output is printed. ...@@ -21,20 +22,20 @@ output is printed.
The command-line flags are all optional. The list of available flags are: The command-line flags are all optional. The list of available flags are:
* `-json` - If specified, the outputs are formatted as a JSON object, with * `-json` - If specified, the outputs are formatted as a JSON object, with
a key per output. If `NAME` is specified, only the output specified will be a key per output. If `NAME` is specified, only the output specified will be
returned. This can be piped into tools such as `jq` for further processing. returned. This can be piped into tools such as `jq` for further processing.
* `-raw` - If specified, Terraform will convert the specified output value to a * `-raw` - If specified, Terraform will convert the specified output value to a
string and print that string directly to the output, without any special string and print that string directly to the output, without any special
formatting. This can be convenient when working with shell scripts, but formatting. This can be convenient when working with shell scripts, but
it only supports string, number, and boolean values. Use `-json` instead it only supports string, number, and boolean values. Use `-json` instead
for processing complex data types. for processing complex data types.
* `-no-color` - If specified, output won't contain any color. * `-no-color` - If specified, output won't contain any color.
* `-state=path` - Path to the state file. Defaults to "terraform.tfstate". * `-state=path` - Path to the state file. Defaults to "terraform.tfstate".
Ignored when [remote state](/language/state/remote) is used. Ignored when [remote state](/docs/language/state/remote.html) is used.
-> **Note:** When using the `-json` or `-raw` command-line flag, any sensitive -> **Note:** When using the `-json` or `-raw` command-line flag, any sensitive
values in Terraform state will be displayed in plain text. For more information, values in Terraform state will be displayed in plain text. For more information,
see [Sensitive Data in State](/language/state/sensitive-data). see [Sensitive Data in State](/docs/language/state/sensitive-data.html).
## Examples ## Examples
......
--- ---
page_title: 'Command: plan' layout: "docs"
description: >- page_title: "Command: plan"
The terraform plan command creates an execution plan with a preview of the sidebar_current: "docs-commands-plan"
changes that Terraform will make to your infrastructure. description: "The terraform plan command creates an execution plan with a preview of the changes that Terraform will make to your infrastructure."
--- ---
# Command: plan # Command: plan
...@@ -31,12 +31,12 @@ to be taken. ...@@ -31,12 +31,12 @@ to be taken.
If you are using Terraform directly in an interactive terminal and you expect If you are using Terraform directly in an interactive terminal and you expect
to apply the changes Terraform proposes, you can alternatively run to apply the changes Terraform proposes, you can alternatively run
[`terraform apply`](/cli/commands/apply) directly. By default, the "apply" command [`terraform apply`](./apply.html) directly. By default, the "apply" command
automatically generates a new plan and prompts for you to approve it. automatically generates a new plan and prompts for you to approve it.
You can use the optional `-out=FILE` option to save the generated plan to a You can use the optional `-out=FILE` option to save the generated plan to a
file on disk, which you can later execute by passing the file to file on disk, which you can later execute by passing the file to
[`terraform apply`](/cli/commands/apply) as an extra argument. This two-step workflow [`terraform apply`](./apply.html) as an extra argument. This two-step workflow
is primarily intended for when is primarily intended for when
[running Terraform in automation](https://learn.hashicorp.com/tutorials/terraform/automate-terraform?in=terraform/automation&utm_source=WEBSITE&utm_medium=WEB_IO&utm_offer=ARTICLE_PAGE&utm_content=DOCS). [running Terraform in automation](https://learn.hashicorp.com/tutorials/terraform/automate-terraform?in=terraform/automation&utm_source=WEBSITE&utm_medium=WEB_IO&utm_offer=ARTICLE_PAGE&utm_content=DOCS).
...@@ -74,9 +74,9 @@ The remaining sections on this page describe the various options: ...@@ -74,9 +74,9 @@ The remaining sections on this page describe the various options:
* **[Planning Options](#planning-options)**: Alongside the special planning * **[Planning Options](#planning-options)**: Alongside the special planning
modes, there are also some options you can set in order to customize the modes, there are also some options you can set in order to customize the
planning process for unusual needs. planning process for unusual needs.
* **[Resource Targeting](#resource-targeting)** is one particular * **[Resource Targeting](#resource-targeting)** is one particular
special planning option that has some important caveats associated special planning option that has some important caveats associated
with it. with it.
* **[Other Options](#other-options)**: These change the behavior of the planning * **[Other Options](#other-options)**: These change the behavior of the planning
command itself, rather than customizing the content of the generated plan. command itself, rather than customizing the content of the generated plan.
...@@ -94,7 +94,7 @@ a different intended outcome: ...@@ -94,7 +94,7 @@ a different intended outcome:
for situations like transient development environments, where the managed for situations like transient development environments, where the managed
objects cease to be useful once the development task is complete. objects cease to be useful once the development task is complete.
Activate destroy mode using the `-destroy` command line option. Activate destroy mode using the `-destroy` command line option.
* **Refresh-only mode:** creates a plan whose goal is only to update the * **Refresh-only mode:** creates a plan whose goal is only to update the
Terraform state and any root module output values to match changes made to Terraform state and any root module output values to match changes made to
...@@ -103,7 +103,7 @@ a different intended outcome: ...@@ -103,7 +103,7 @@ a different intended outcome:
workflow (e.g. while responding to an incident) and you now need to reconcile workflow (e.g. while responding to an incident) and you now need to reconcile
Terraform's records with those changes. Terraform's records with those changes.
Activate refresh-only mode using the `-refresh-only` command line option. Activate refresh-only mode using the `-refresh-only` command line option.
In situations where we need to discuss the default planning mode that Terraform In situations where we need to discuss the default planning mode that Terraform
uses when none of the alternative modes are selected, we refer to it as uses when none of the alternative modes are selected, we refer to it as
...@@ -118,7 +118,7 @@ one alternative mode at the same time. ...@@ -118,7 +118,7 @@ one alternative mode at the same time.
-> **Note:** In Terraform v0.15 and earlier, the `-destroy` option is -> **Note:** In Terraform v0.15 and earlier, the `-destroy` option is
supported only by the `terraform plan` command, and not by the supported only by the `terraform plan` command, and not by the
`terraform apply` command. To create and apply a plan in destroy mode in `terraform apply` command. To create and apply a plan in destroy mode in
earlier versions you must run [`terraform destroy`](/cli/commands/destroy). earlier versions you must run [`terraform destroy`](./destroy.html).
-> **Note:** The `-refresh-only` option is available only in Terraform v0.15.4 -> **Note:** The `-refresh-only` option is available only in Terraform v0.15.4
and later. and later.
...@@ -140,62 +140,62 @@ the previous section, are also available with the same meanings on ...@@ -140,62 +140,62 @@ the previous section, are also available with the same meanings on
* `-refresh=false` - Disables the default behavior of synchronizing the * `-refresh=false` - Disables the default behavior of synchronizing the
Terraform state with remote objects before checking for configuration changes. Terraform state with remote objects before checking for configuration changes.
This option can potentially make the planning operation faster by reducing This option can potentially make the planning operation faster by reducing
the number of remote API requests, but it comes at the expense of having the number of remote API requests, but it comes at the expense of having
Terraform not take into account any changes that might've happened outside Terraform not take into account any changes that might've happened outside
of Terraform, and thus the resulting plan may not be complete or correct. of Terraform, and thus the resulting plan may not be complete or correct.
This option is not available in the "refresh only" planning mode, because This option is not available in the "refresh only" planning mode, because
it would effectively disable the entirety of the planning operation in that it would effectively disable the entirety of the planning operation in that
case. case.
* `-replace=ADDRESS` - Instructs Terraform to plan to replace the single * `-replace=ADDRESS` - Instructs Terraform to plan to replace the single
resource instance with the given address. If the given instance would resource instance with the given address. If the given instance would
normally have caused only an "update" action, or no action at all, then normally have caused only an "update" action, or no action at all, then
Terraform will choose a "replace" action instead. Terraform will choose a "replace" action instead.
You can use this option if you have learned that a particular remote object You can use this option if you have learned that a particular remote object
has become degraded in some way. If you are using immutable infrastructure has become degraded in some way. If you are using immutable infrastructure
patterns then you may wish to respond to that by replacing the patterns then you may wish to respond to that by replacing the
malfunctioning object with a new object that has the same configuration. malfunctioning object with a new object that has the same configuration.
This option is allowed only in the normal planning mode, so this option This option is allowed only in the normal planning mode, so this option
is incompatible with the `-destroy` option. is incompatible with the `-destroy` option.
The `-replace=...` option is available only from Terraform v0.15.2 onwards. The `-replace=...` option is available only from Terraform v0.15.2 onwards.
For earlier versions, you can achieve a similar effect (with some caveats) For earlier versions, you can achieve a similar effect (with some caveats)
using [`terraform taint`](/cli/commands/taint). using [`terraform taint`](./taint.html).
* `-target=ADDRESS` - Instructs Terraform to focus its planning efforts only * `-target=ADDRESS` - Instructs Terraform to focus its planning efforts only
on resource instances which match the given address and on any objects that on resource instances which match the given address and on any objects that
those instances depend on. those instances depend on.
This command is for exceptional use only. See This command is for exceptional use only. See
[Resource Targeting](#resource-targeting) [Resource Targeting](#resource-targeting)
below for more information. below for more information.
* `-var 'NAME=VALUE'` - Sets a value for a single * `-var 'NAME=VALUE'` - Sets a value for a single
[input variable](/language/values/variables) declared in the [input variable](/docs/language/values/variables.html) declared in the
root module of the configuration. Use this option multiple times to set root module of the configuration. Use this option multiple times to set
more than one variable. For more information see more than one variable. For more information see
[Input Variables on the Command Line](#input-variables-on-the-command-line), [Input Variables on the Command Line](#input-variables-on-the-command-line),
below. below.
* `-var-file=FILENAME` - Sets values for potentially many * `-var-file=FILENAME` - Sets values for potentially many
[input variables](/language/values/variables) declared in the [input variables](/docs/language/values/variables.html) declared in the
root module of the configuration, using definitions from a root module of the configuration, using definitions from a
["tfvars" file](/language/values/variables#variable-definitions-tfvars-files). ["tfvars" file](/docs/language/values/variables.html#variable-definitions-tfvars-files).
Use this option multiple times to include values from more than one file. Use this option multiple times to include values from more than one file.
There are several other ways to set values for input variables in the root There are several other ways to set values for input variables in the root
module, aside from the `-var` and `-var-file` options. For more information, module, aside from the `-var` and `-var-file` options. For more information,
see see
[Assigning Values to Root Module Variables](/language/values/variables#assigning-values-to-root-module-variables). [Assigning Values to Root Module Variables](/docs/language/values/variables.html#assigning-values-to-root-module-variables).
### Input Variables on the Command Line ### Input Variables on the Command Line
You can use the `-var` command line option to specify values for You can use the `-var` command line option to specify values for
[input variables](/language/values/variables) declared in your [input variables](/docs/language/values/variables.html) declared in your
root module. root module.
However, to do so will require writing a command line that is parsable both However, to do so will require writing a command line that is parsable both
...@@ -242,7 +242,7 @@ so we do not recommend using Terraform with PowerShell when you are on Windows. ...@@ -242,7 +242,7 @@ so we do not recommend using Terraform with PowerShell when you are on Windows.
Use Windows Command Prompt instead. Use Windows Command Prompt instead.
The appropriate syntax for writing the variable value is different depending The appropriate syntax for writing the variable value is different depending
on the variable's [type constraint](/language/expressions/type-constraints). on the variable's [type constraint](/docs/language/expressions/type-constraints.html).
The primitive types `string`, `number`, and `bool` all expect a direct string The primitive types `string`, `number`, and `bool` all expect a direct string
value with no special punctuation except that required by your shell, as value with no special punctuation except that required by your shell, as
shown in the above examples. For all other type constraints, including list, shown in the above examples. For all other type constraints, including list,
...@@ -262,7 +262,8 @@ terraform plan -var "name=[\"a\", \"b\", \"c\"]" ...@@ -262,7 +262,8 @@ terraform plan -var "name=[\"a\", \"b\", \"c\"]"
Similar constraints apply when setting input variables using environment Similar constraints apply when setting input variables using environment
variables. For more information on the various methods for setting root module variables. For more information on the various methods for setting root module
input variables, see input variables, see
[Assigning Values to Root Module Variables](/language/values/variables#assigning-values-to-root-module-variables). [Assigning Values to Root Module Variables](/docs/language/values/variables.html#assigning-values-to-root-module-variables).
### Resource Targeting ### Resource Targeting
...@@ -270,7 +271,7 @@ input variables, see ...@@ -270,7 +271,7 @@ input variables, see
You can use the `-target` option to focus Terraform's attention on only a You can use the `-target` option to focus Terraform's attention on only a
subset of resources. subset of resources.
You can use [resource address syntax](/cli/state/resource-addressing) You can use [resource address syntax](/docs/cli/state/resource-addressing.html)
to specify the constraint. Terraform interprets the resource address as follows: to specify the constraint. Terraform interprets the resource address as follows:
* If the given address identifies one specific resource instance, Terraform * If the given address identifies one specific resource instance, Terraform
...@@ -295,14 +296,14 @@ that those selections depend on either directly or indirectly. ...@@ -295,14 +296,14 @@ that those selections depend on either directly or indirectly.
This targeting capability is provided for exceptional circumstances, such This targeting capability is provided for exceptional circumstances, such
as recovering from mistakes or working around Terraform limitations. It as recovering from mistakes or working around Terraform limitations. It
is _not recommended_ to use `-target` for routine operations, since this can is *not recommended* to use `-target` for routine operations, since this can
lead to undetected configuration drift and confusion about how the true state lead to undetected configuration drift and confusion about how the true state
of resources relates to configuration. of resources relates to configuration.
Instead of using `-target` as a means to operate on isolated portions of very Instead of using `-target` as a means to operate on isolated portions of very
large configurations, prefer instead to break large configurations into large configurations, prefer instead to break large configurations into
several smaller configurations that can each be independently applied. several smaller configurations that can each be independently applied.
[Data sources](/language/data-sources/) can be used to access [Data sources](/docs/language/data-sources/index.html) can be used to access
information about resources created in other configurations, allowing information about resources created in other configurations, allowing
a complex system architecture to be broken down into more manageable parts a complex system architecture to be broken down into more manageable parts
that can be updated independently. that can be updated independently.
...@@ -338,11 +339,11 @@ The available options are: ...@@ -338,11 +339,11 @@ The available options are:
This implies `-input=false`, so the configuration must have no unassigned This implies `-input=false`, so the configuration must have no unassigned
variable values to continue. variable values to continue.
[machine-readable-ui]: /internals/machine-readable-ui [machine-readable-ui]: /docs/internals/machine-readable-ui.html
* `-lock=false` - Don't hold a state lock during the operation. This is * `-lock=false` - Don't hold a state lock during the operation. This is
dangerous if others might concurrently run commands against the same dangerous if others might concurrently run commands against the same
workspace. workspace.
* `-lock-timeout=DURATION` - Unless locking is disabled with `-lock=false`, * `-lock-timeout=DURATION` - Unless locking is disabled with `-lock=false`,
instructs Terraform to retry acquiring a lock for a period of time before instructs Terraform to retry acquiring a lock for a period of time before
...@@ -358,28 +359,28 @@ The available options are: ...@@ -358,28 +359,28 @@ The available options are:
the planned changes, and to some other Terraform commands that can work with the planned changes, and to some other Terraform commands that can work with
saved plan files. saved plan files.
Terraform will allow any filename for the plan file, but a typical Terraform will allow any filename for the plan file, but a typical
convention is to name it `tfplan`. **Do not** name the file with a suffix convention is to name it `tfplan`. **Do not** name the file with a suffix
that Terraform recognizes as another file format; if you use a `.tf` suffix that Terraform recognizes as another file format; if you use a `.tf` suffix
then Terraform will try to interpret the file as a configuration source then Terraform will try to interpret the file as a configuration source
file, which will then cause syntax errors for subsequent commands. file, which will then cause syntax errors for subsequent commands.
The generated file is not in any standard format intended for consumption The generated file is not in any standard format intended for consumption
by other software, but the file _does_ contain your full configuration, by other software, but the file _does_ contain your full configuration,
all of the values associated with planned changes, and all of the plan all of the values associated with planned changes, and all of the plan
options including the input variables. If your plan includes any sort of options including the input variables. If your plan includes any sort of
sensitive data, even if obscured in Terraform's terminal output, it will sensitive data, even if obscured in Terraform's terminal output, it will
be saved in cleartext in the plan file. You should therefore treat any be saved in cleartext in the plan file. You should therefore treat any
saved plan files as potentially-sensitive artifacts. saved plan files as potentially-sensitive artifacts.
* `-parallelism=n` - Limit the number of concurrent operations as Terraform * `-parallelism=n` - Limit the number of concurrent operations as Terraform
[walks the graph](/internals/graph#walking-the-graph). Defaults [walks the graph](/docs/internals/graph.html#walking-the-graph). Defaults
to 10. to 10.
For configurations using For configurations using
[the `local` backend](/language/settings/backends/local) only, [the `local` backend](/docs/language/settings/backends/local.html) only,
`terraform plan` accepts the legacy command line option `terraform plan` accepts the legacy command line option
[`-state`](/language/settings/backends/local#command-line-arguments). [`-state`](/docs/language/settings/backends/local.html#command-line-arguments).
### Passing a Different Configuration Directory ### Passing a Different Configuration Directory
...@@ -389,7 +390,7 @@ module instead of the current working directory. ...@@ -389,7 +390,7 @@ module instead of the current working directory.
That usage was deprecated in Terraform v0.14 and removed in Terraform v0.15. That usage was deprecated in Terraform v0.14 and removed in Terraform v0.15.
If your workflow relies on overriding the root module directory, use If your workflow relies on overriding the root module directory, use
[the `-chdir` global option](/cli/commands/#switching-working-directory-with-chdir) [the `-chdir` global option](./#switching-working-directory-with-chdir)
instead, which works across all commands and makes Terraform consistently look instead, which works across all commands and makes Terraform consistently look
in the given directory for all files it would normally read or write in the in the given directory for all files it would normally read or write in the
current working directory. current working directory.
...@@ -397,6 +398,6 @@ current working directory. ...@@ -397,6 +398,6 @@ current working directory.
If your previous use of this legacy pattern was also relying on Terraform If your previous use of this legacy pattern was also relying on Terraform
writing the `.terraform` subdirectory into the current working directory even writing the `.terraform` subdirectory into the current working directory even
though the root module directory was overridden, use though the root module directory was overridden, use
[the `TF_DATA_DIR` environment variable](/cli/config/environment-variables#tf_data_dir) [the `TF_DATA_DIR` environment variable](/docs/cli/config/environment-variables.html#tf_data_dir)
to direct Terraform to write the `.terraform` directory to a location other to direct Terraform to write the `.terraform` directory to a location other
than the current working directory. than the current working directory.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment