github.com/pdecat/terraform@v0.11.9-beta1/website/docs/commands/console.html.markdown (about)

     1  ---
     2  layout: "docs"
     3  page_title: "Command: console"
     4  sidebar_current: "docs-commands-console"
     5  description: |-
     6    The `terraform console` command creates an interactive console for using [interpolations](/docs/configuration/interpolation.html).
     7  ---
     8  
     9  # Command: console
    10  
    11  The `terraform console` command creates an interactive console for
    12  using [interpolations](/docs/configuration/interpolation.html).
    13  
    14  ## Usage
    15  
    16  Usage: `terraform console [options] [dir]`
    17  
    18  This opens an interactive console for experimenting with interpolations.
    19  This is useful for testing interpolations before using them in configurations
    20  as well as interacting with an existing [state](/docs/state/index.html).
    21  
    22  If a state file doesn't exist, the console still works and can be used
    23  to experiment with supported interpolation functions. Try entering some basic
    24  math such as `1 + 5` to see.
    25  
    26  The `dir` argument can be used to open a console for a specific Terraform
    27  configuration directory. This will load any state from that directory as
    28  well as the configuration. This defaults to the current working directory.
    29  The `console` command does not require Terraform state or configuration
    30  to function.
    31  
    32  The command-line flags are all optional. The list of available flags are:
    33  
    34  * `-state=path` - Path to the state file. Defaults to `terraform.tfstate`.
    35    A state file doesn't need to exist.
    36  
    37  You can close the console with the `exit` command or by using Control-C
    38  or Control-D.
    39  
    40  ## Scripting
    41  
    42  The `terraform console` command can be used in non-interactive scripts
    43  by piping newline-separated commands to it. Only the output from the
    44  final command is outputted unless an error occurs earlier.
    45  
    46  An example is shown below:
    47  
    48  ```shell
    49  $ echo "1 + 5" | terraform console
    50  6
    51  ```
    52  
    53  ## Remote State
    54  
    55  The `terraform console` command will read configured state even if it
    56  is [remote](/docs/state/remote.html). This is great for scripting
    57  state reading in CI environments or other remote scenarios.
    58  
    59  After configuring remote state, run a `terraform remote pull` command
    60  to sync state locally. The `terraform console` command will use this
    61  state for operations.
    62  
    63  Because the console currently isn't able to modify state in any way,
    64  this is a one way operation and you don't need to worry about remote
    65  state conflicts in any way.