website: Fix references to the now-defunct "Interpolation" page
This has been replaced with an "Expressions" page. Also includes a number of changes to Markdown style to conform to our usual conventions, applied automatically by my editor while making these changes.
This commit is contained in:
parent
6549f24d88
commit
b2e8987f7e
|
@ -3,47 +3,48 @@ layout: "docs"
|
||||||
page_title: "Command: console"
|
page_title: "Command: console"
|
||||||
sidebar_current: "docs-commands-console"
|
sidebar_current: "docs-commands-console"
|
||||||
description: |-
|
description: |-
|
||||||
The `terraform console` command creates an interactive console for using [interpolations](/docs/configuration/interpolation.html).
|
The `terraform console` command provides an interactive console for
|
||||||
|
evaluting expressions.
|
||||||
---
|
---
|
||||||
|
|
||||||
# Command: console
|
# Command: console
|
||||||
|
|
||||||
The `terraform console` command creates an interactive console for
|
The `terraform console` command provides an interactive console for
|
||||||
using [interpolations](/docs/configuration/interpolation.html).
|
evaluating [expressions](/docs/configuration/expressions.html).
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Usage: `terraform console [options] [dir]`
|
Usage: `terraform console [options] [dir]`
|
||||||
|
|
||||||
This opens an interactive console for experimenting with interpolations.
|
This command provides an interative command-line console for evaluating and
|
||||||
This is useful for testing interpolations before using them in configurations
|
experimenting with [expressions](/docs/configuration/expressions.html).
|
||||||
as well as interacting with an existing [state](/docs/state/index.html).
|
This is useful for testing interpolations before using them in configurations,
|
||||||
|
and for interacting with any values currently saved in
|
||||||
|
[state](/docs/state/index.html).
|
||||||
|
|
||||||
If a state file doesn't exist, the console still works and can be used
|
If the current state is empty or has not yet been created, the console can be
|
||||||
to experiment with supported interpolation functions. Try entering some basic
|
used to experiment with the expression syntax and
|
||||||
math such as `1 + 5` to see.
|
[built-in functions](/docs/configuration/functions.html).
|
||||||
|
|
||||||
The `dir` argument can be used to open a console for a specific Terraform
|
The `dir` argument specifies the directory of the root module to use.
|
||||||
configuration directory. This will load any state from that directory as
|
If a path is not specified, the current working directory is used.
|
||||||
well as the configuration. This defaults to the current working directory.
|
|
||||||
The `console` command does not require Terraform state or configuration
|
|
||||||
to function.
|
|
||||||
|
|
||||||
The command-line flags are all optional. The list of available flags are:
|
The supported options are:
|
||||||
|
|
||||||
* `-state=path` - Path to the state file. Defaults to `terraform.tfstate`.
|
* `-state=path` - Path to a local state file. Expressions will be evaluated
|
||||||
A state file doesn't need to exist.
|
using values from this state file. If not specified, the state associated
|
||||||
|
with the current [workspace](/docs/state/workspaces.html) is used.
|
||||||
|
|
||||||
You can close the console with the `exit` command or by using Control-C
|
You can close the console with the `exit` command or by pressing Control-C
|
||||||
or Control-D.
|
or Control-D.
|
||||||
|
|
||||||
## Scripting
|
## Scripting
|
||||||
|
|
||||||
The `terraform console` command can be used in non-interactive scripts
|
The `terraform console` command can be used in non-interactive scripts
|
||||||
by piping newline-separated commands to it. Only the output from the
|
by piping newline-separated commands to it. Only the output from the
|
||||||
final command is outputted unless an error occurs earlier.
|
final command is printed unless an error occurs earlier.
|
||||||
|
|
||||||
An example is shown below:
|
For example:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
$ echo "1 + 5" | terraform console
|
$ echo "1 + 5" | terraform console
|
||||||
|
@ -52,14 +53,6 @@ $ echo "1 + 5" | terraform console
|
||||||
|
|
||||||
## Remote State
|
## Remote State
|
||||||
|
|
||||||
The `terraform console` command will read configured state even if it
|
If [remote state](/docs/state/remote.html) is used by the current backend,
|
||||||
is [remote](/docs/state/remote.html). This is great for scripting
|
Terraform will read the state for the current workspace from the backend
|
||||||
state reading in CI environments or other remote scenarios.
|
before evaluating any expressions.
|
||||||
|
|
||||||
After configuring remote state, run a `terraform remote pull` command
|
|
||||||
to sync state locally. The `terraform console` command will use this
|
|
||||||
state for operations.
|
|
||||||
|
|
||||||
Because the console currently isn't able to modify state in any way,
|
|
||||||
this is a one way operation and you don't need to worry about remote
|
|
||||||
state conflicts in any way.
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ If you now run `terraform apply`, you see how this works.
|
||||||
|
|
||||||
It is sometimes useful to embed files within the module that aren't Terraform configuration files, such as a script to provision a resource or a file to upload.
|
It is sometimes useful to embed files within the module that aren't Terraform configuration files, such as a script to provision a resource or a file to upload.
|
||||||
|
|
||||||
In these cases, you can't use a relative path, since paths in Terraform are generally relative to the working directory from which Terraform was executed. Instead, you want to use a module-relative path. To do this, you should use the [path interpolated variables](/docs/configuration/interpolation.html).
|
In these cases, you can't use a relative path, since paths in Terraform are generally relative to the working directory from which Terraform was executed. Instead, use a module-relative path, by interpolating `path.module`:
|
||||||
|
|
||||||
```hcl
|
```hcl
|
||||||
resource "aws_instance" "server" {
|
resource "aws_instance" "server" {
|
||||||
|
@ -84,8 +84,6 @@ resource "aws_instance" "server" {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Here we use `${path.module}` to get a module-relative path.
|
|
||||||
|
|
||||||
## Nested Modules
|
## Nested Modules
|
||||||
|
|
||||||
You can nest a module within another module. This module will be hidden from your root configuration, so you'll have to re-expose any
|
You can nest a module within another module. This module will be hidden from your root configuration, so you'll have to re-expose any
|
||||||
|
@ -118,13 +116,13 @@ standard structure.
|
||||||
|
|
||||||
* **README**. The root module and any nested modules should have README
|
* **README**. The root module and any nested modules should have README
|
||||||
files. This file should be named `README` or `README.md`. The latter will
|
files. This file should be named `README` or `README.md`. The latter will
|
||||||
be treated as markdown. There should be a description of the module and
|
be treated as markdown. There should be a description of the module and
|
||||||
what it should be used for. If you want to include an example for how this
|
what it should be used for. If you want to include an example for how this
|
||||||
module can be used in combination with other resources, put it in an [examples
|
module can be used in combination with other resources, put it in an [examples
|
||||||
directory like this](https://github.com/hashicorp/terraform-aws-consul/tree/master/examples).
|
directory like this](https://github.com/hashicorp/terraform-aws-consul/tree/master/examples).
|
||||||
Consider including a visual diagram depicting the infrastructure resources
|
Consider including a visual diagram depicting the infrastructure resources
|
||||||
the module may create and their relationship. The README doesn't need to
|
the module may create and their relationship. The README doesn't need to
|
||||||
document inputs or outputs of the module because tooling will automatically
|
document inputs or outputs of the module because tooling will automatically
|
||||||
generate this. If you are linking to a file or embedding an image contained
|
generate this. If you are linking to a file or embedding an image contained
|
||||||
in the repository itself, use a commit-specific absolute URL so the link won't
|
in the repository itself, use a commit-specific absolute URL so the link won't
|
||||||
point to the wrong version of a resource in the future.
|
point to the wrong version of a resource in the future.
|
||||||
|
|
|
@ -16,8 +16,8 @@ resource. The `chef` provisioner supports both `ssh` and `winrm` type
|
||||||
|
|
||||||
The `chef` provisioner has some prerequisites for specific connection types:
|
The `chef` provisioner has some prerequisites for specific connection types:
|
||||||
|
|
||||||
- For `ssh` type connections, `cURL` must be available on the remote host.
|
* For `ssh` type connections, `cURL` must be available on the remote host.
|
||||||
- For `winrm` connections, `PowerShell 2.0` must be available on the remote host.
|
* For `winrm` connections, `PowerShell 2.0` must be available on the remote host.
|
||||||
|
|
||||||
Without these prerequisites, your provisioning execution will fail.
|
Without these prerequisites, your provisioning execution will fail.
|
||||||
|
|
||||||
|
@ -62,8 +62,8 @@ resource "aws_instance" "web" {
|
||||||
The following arguments are supported:
|
The following arguments are supported:
|
||||||
|
|
||||||
* `attributes_json (string)` - (Optional) A raw JSON string with initial node attributes
|
* `attributes_json (string)` - (Optional) A raw JSON string with initial node attributes
|
||||||
for the new node. These can also be loaded from a file on disk using the [`file()`
|
for the new node. These can also be loaded from a file on disk using
|
||||||
interpolation function](/docs/configuration/interpolation.html#file_path_).
|
[the `file` function](/docs/configuration/functions/file.html).
|
||||||
|
|
||||||
* `channel (string)` - (Optional) The Chef Client release channel to install from. If not
|
* `channel (string)` - (Optional) The Chef Client release channel to install from. If not
|
||||||
set, the `stable` channel will be used.
|
set, the `stable` channel will be used.
|
||||||
|
@ -131,8 +131,8 @@ The following arguments are supported:
|
||||||
|
|
||||||
* `secret_key (string)` - (Optional) The contents of the secret key that is used
|
* `secret_key (string)` - (Optional) The contents of the secret key that is used
|
||||||
by the Chef Client to decrypt data bags on the Chef Server. The key will be uploaded to the remote
|
by the Chef Client to decrypt data bags on the Chef Server. The key will be uploaded to the remote
|
||||||
machine. This can also be loaded from a file on disk using the [`file()` interpolation
|
machine. This can also be loaded from a file on disk using
|
||||||
function](/docs/configuration/interpolation.html#file_path_).
|
[the `file` function](/docs/configuration/functions/file.html).
|
||||||
|
|
||||||
* `server_url (string)` - (Required) The URL to the Chef server. This includes the path to
|
* `server_url (string)` - (Required) The URL to the Chef server. This includes the path to
|
||||||
the organization. See the example.
|
the organization. See the example.
|
||||||
|
@ -153,12 +153,12 @@ The following arguments are supported:
|
||||||
the new Chef Client and optionally configure Chef Vaults.
|
the new Chef Client and optionally configure Chef Vaults.
|
||||||
|
|
||||||
* `user_key (string)` - (Required) The contents of the user key that will be used to
|
* `user_key (string)` - (Required) The contents of the user key that will be used to
|
||||||
authenticate with the Chef Server. This can also be loaded from a file on disk using the [`file()`
|
authenticate with the Chef Server. This can also be loaded from a file on disk using
|
||||||
interpolation function](/docs/configuration/interpolation.html#file_path_).
|
[the `file` function](/docs/configuration/functions/file.html).
|
||||||
|
|
||||||
* `vault_json (string)` - (Optional) A raw JSON string with Chef Vaults and Items to which the new node
|
* `vault_json (string)` - (Optional) A raw JSON string with Chef Vaults and Items to which the new node
|
||||||
should have access. These can also be loaded from a file on disk using the
|
should have access. These can also be loaded from a file on disk using
|
||||||
[`file()` interpolation function](/docs/configuration/interpolation.html#file_path_).
|
[the `file` function](/docs/configuration/functions/file.html).
|
||||||
|
|
||||||
* `version (string)` - (Optional) The Chef Client version to install on the remote machine.
|
* `version (string)` - (Optional) The Chef Client version to install on the remote machine.
|
||||||
If not set, the latest available version will be installed.
|
If not set, the latest available version will be installed.
|
||||||
|
|
|
@ -73,8 +73,8 @@ provisioner "file" {
|
||||||
**Additional arguments only supported by the `ssh` connection type:**
|
**Additional arguments only supported by the `ssh` connection type:**
|
||||||
|
|
||||||
* `private_key` - The contents of an SSH key to use for the connection. These can
|
* `private_key` - The contents of an SSH key to use for the connection. These can
|
||||||
be loaded from a file on disk using the [`file()` interpolation
|
be loaded from a file on disk using
|
||||||
function](/docs/configuration/interpolation.html#file_path_). This takes
|
[the `file` function](/docs/configuration/functions/file.html). This takes
|
||||||
preference over the password if provided.
|
preference over the password if provided.
|
||||||
|
|
||||||
* `agent` - Set to `false` to disable using `ssh-agent` to authenticate. On Windows the
|
* `agent` - Set to `false` to disable using `ssh-agent` to authenticate. On Windows the
|
||||||
|
@ -97,6 +97,7 @@ provisioner "file" {
|
||||||
* `cacert` - The CA certificate to validate against.
|
* `cacert` - The CA certificate to validate against.
|
||||||
|
|
||||||
<a id="bastion"></a>
|
<a id="bastion"></a>
|
||||||
|
|
||||||
## Connecting through a Bastion Host with SSH
|
## Connecting through a Bastion Host with SSH
|
||||||
|
|
||||||
The `ssh` connection also supports the following fields to facilitate connnections via a
|
The `ssh` connection also supports the following fields to facilitate connnections via a
|
||||||
|
@ -118,6 +119,6 @@ The `ssh` connection also supports the following fields to facilitate connnectio
|
||||||
Defaults to the value of the `password` field.
|
Defaults to the value of the `password` field.
|
||||||
|
|
||||||
* `bastion_private_key` - The contents of an SSH key file to use for the bastion
|
* `bastion_private_key` - The contents of an SSH key file to use for the bastion
|
||||||
host. These can be loaded from a file on disk using the [`file()`
|
host. These can be loaded from a file on disk using
|
||||||
interpolation function](/docs/configuration/interpolation.html#file_path_).
|
[the `file` function](/docs/configuration/functions/file.html).
|
||||||
Defaults to the value of the `private_key` field.
|
Defaults to the value of the `private_key` field.
|
||||||
|
|
Loading…
Reference in New Issue