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_state data 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:

ArgumentDescriptionTypeRequired?
valueThe value Terraform returns for this output.ExpressionRequired
descriptionA description of the output’s purpose and how to use it.StringOptional
sensitiveSpecifies if Terraform hides this value in CLI output.BooleanOptional
ephemeralSpecifies whether to prevent storing this value in state.BooleanOptional
depends_onA list of explicit dependencies for this output.ListOptional
preconditionA condition to validate before computing the output or storing it in state.BlockOptional

Sensitive

If you use the terraform output command with the -json or -raw command-line flags, Terraform displays sensitive values in plain text.