We have these funny extra options that date back to before Terraform even had remote state, which we've preserved along the way by most recently incorporating them as special-case overrides for the local backend. The documentation we had for these has grown less accurate over time as the details have shifted, and was in many cases missing the requisite caveats that they are only for the local backend and that backend configuration is the modern, preferred way to deal with the use-cases they were intended for. We always have a bit of a tension with this sort of legacy option because we want to keep them documented just enough to be useful to someone who finds an existing script/etc using them and wants to know what they do, but not to take up so much space that they might distract users from finding the modern alternative they should consider instead. As a compromise in that vein here I've created a new section about these options under the local backend documentation, which then gives us the space to go into some detail about the various behaviors and interactions and also to discuss their history and our recommended alternatives. I then simplified all of the other mentions of these in command documentation to just link to or refer to the local backend documentation. My hope then is that folks who need to know what these do can still find the docs, but that information can be kept out of the direct path of new users so they can focus on learning about remote backends instead. This is certainly not the most ideal thing ever, but it seemed like the best compromise between the competing priorities I described above.
1.7 KiB
layout, page_title, sidebar_current, description
| layout | page_title | sidebar_current | description |
|---|---|---|---|
| docs | Command: console | docs-commands-console | The `terraform console` command provides an interactive console for evaluting expressions. |
Command: console
The terraform console command provides an interactive console for
evaluating expressions.
Usage
Usage: terraform console [options]
This command provides an interactive command-line console for evaluating and experimenting with expressions. This is useful for testing interpolations before using them in configurations, and for interacting with any values currently saved in state.
If the current state is empty or has not yet been created, the console can be used to experiment with the expression syntax and built-in functions.
You can close the console with the exit command or by pressing Control-C
or Control-D.
For configurations using
the local backend only,
terraform console accepts the legacy command line option
-state.
Scripting
The terraform console command can be used in non-interactive scripts
by piping newline-separated commands to it. Only the output from the
final command is printed unless an error occurs earlier.
For example:
$ echo "1 + 5" | terraform console
6
Remote State
If remote state is used by the current backend, Terraform will read the state for the current workspace from the backend before evaluating any expressions.