Contents
The output block lets you expose information about your infrastructure. The value of an output block is similar to a return value in other programming languages. The output block serves four main purposes in Terraform:
- Child modules can expose resource attributes to parent modules.
- Root modules can display values in CLI output.
- Other Terraform configurations using remote state can access root module outputs with the
terraform_remote_statedata source. - Passing information from a Terraform operation to an automation tool.
Output Block
output "<LABEL>" {
value = <EXPRESSION>
description = "<STRING>"
sensitive = <true|false>
ephemeral = <true|false>
depends_on = [<REFERENCE>]
precondition {
condition = <EXPRESSION>
error_message = "<STRING>"
}
}The following arguments are supported in an output block:
| Argument | Description | Type | Required? |
|---|---|---|---|
value | The value Terraform returns for this output. | Expression | Required |
description | A description of the output’s purpose and how to use it. | String | Optional |
sensitive | Specifies if Terraform hides this value in CLI output. | Boolean | Optional |
ephemeral | Specifies whether to prevent storing this value in state. | Boolean | Optional |
depends_on | A list of explicit dependencies for this output. | List | Optional |
precondition | A condition to validate before computing the output or storing it in state. | Block | Optional |
Sensitive
If you use the terraform output command with the -json or -raw command-line flags, Terraform displays sensitive values in plain text.