2014-07-28 19:43:00 +02:00
---
layout: "docs"
page_title: "Configuring Outputs"
sidebar_current: "docs-config-outputs"
2014-10-22 05:21:56 +02:00
description: |-
Outputs define values that will be highlighted to the user when Terraform applies, and can be queried easily using the output command. Output usage is covered in more detail in the getting started guide. This page covers configuration syntax for outputs.
2014-07-28 19:43:00 +02:00
---
# Output Configuration
Outputs define values that will be highlighted to the user
when Terraform applies, and can be queried easily using the
[output command ](/docs/commands/output.html ). Output usage
is covered in more detail in the
[getting started guide ](/intro/getting-started/outputs.html ).
This page covers configuration syntax for outputs.
Terraform knows a lot about the infrastructure it manages.
2016-08-21 21:17:31 +02:00
Most resources have attributes associated with them, and
outputs are a way to easily extract and query that information.
2014-07-28 19:43:00 +02:00
2016-08-21 21:17:31 +02:00
This page assumes you are familiar with the
2014-07-28 19:43:00 +02:00
[configuration syntax ](/docs/configuration/syntax.html )
already.
## Example
2016-08-21 21:17:31 +02:00
A simple output configuration looks like the following:
2014-07-28 19:43:00 +02:00
2017-04-05 17:29:27 +02:00
```hcl
2014-07-28 19:43:00 +02:00
output "address" {
2016-08-21 21:17:31 +02:00
value = "${aws_instance.db.public_dns}"
}
```
This will output a string value corresponding to the public
DNS address of the Terraform-defined AWS instance named "db". It
2017-05-30 01:12:24 +02:00
is possible to export complex data types like maps and lists as
2016-08-21 21:17:31 +02:00
well:
2017-04-05 17:29:27 +02:00
```hcl
2016-08-21 21:17:31 +02:00
output "addresses" {
value = ["${aws_instance.web.*.public_dns}"]
2014-07-28 19:43:00 +02:00
}
```
2014-08-07 09:19:56 +02:00
## Description
2014-07-28 19:43:00 +02:00
The `output` block configures a single output variable. Multiple
output variables can be configured with multiple output blocks.
The `NAME` given to the output block is the name used to reference
2018-02-13 04:33:57 +01:00
the output variable. It must conform to Terraform variable naming
conventions if it is to be used as an input to other modules.
2014-07-28 19:43:00 +02:00
Within the block (the `{ }` ) is configuration for the output.
These are the parameters that can be set:
2017-04-05 17:29:27 +02:00
- `value` (required) - The value of the output. This can be a string, list, or
map. This usually includes an interpolation since outputs that are static
aren't usually useful.
2016-07-12 00:37:51 +02:00
2017-04-06 10:46:18 +02:00
- `description` (optional) - A human-friendly description for the output. This
is primarily for documentation for users using your Terraform configuration. A
future version of Terraform will expose these descriptions as part of some
Terraform CLI command.
2017-04-05 17:29:27 +02:00
- `depends_on` (list of strings) - Explicit dependencies that this output has.
These dependencies will be created before this output value is processed. The
dependencies are in the format of `TYPE.NAME` , for example `aws_instance.web` .
2016-11-12 03:17:46 +01:00
2017-04-05 17:29:27 +02:00
- `sensitive` (optional, boolean) - See below.
2014-07-28 19:43:00 +02:00
## Syntax
The full syntax is:
2017-04-05 17:29:27 +02:00
```text
2014-07-28 19:43:00 +02:00
output NAME {
2016-07-12 00:37:51 +02:00
value = VALUE
2014-07-28 19:43:00 +02:00
}
```
2016-05-09 21:46:07 +02:00
## Sensitive Outputs
Outputs can be marked as containing sensitive material by setting the
`sensitive` attribute to `true` , like this:
2017-04-05 17:29:27 +02:00
```hcl
2016-05-09 21:46:07 +02:00
output "sensitive" {
2016-07-12 00:37:51 +02:00
sensitive = true
value = VALUE
2016-05-09 21:46:07 +02:00
}
```
When outputs are displayed on-screen following a `terraform apply` or
`terraform refresh` , sensitive outputs are redacted, with `<sensitive>`
displayed in place of their value.
### Limitations of Sensitive Outputs
2017-04-05 17:29:27 +02:00
- The values of sensitive outputs are still stored in the Terraform state, and
available using the `terraform output` command, so cannot be relied on as a
sole means of protecting values.
- Sensitivity is not tracked internally, so if the output is interpolated in
2016-07-12 00:37:51 +02:00
another module into a resource, the value will be displayed.