github.com/hugorut/terraform@v1.1.3/website/docs/language/configuration-0-11/outputs.mdx (about)

     1  ---
     2  page_title: Output Values - 0.11 Configuration Language
     3  description: >-
     4    Outputs define values that will be highlighted to the user when Terraform
     5    applies, and can be queried easily using the output command. Output usage is
     6    covered in more detail in the getting started guide. This page covers
     7    configuration syntax for outputs.
     8  ---
     9  
    10  # Output Values
    11  
    12  -> **Note:** This page is about Terraform 0.11 and earlier. For Terraform 0.12
    13  and later, see
    14  [Configuration Language: Output Values](/language/values/outputs).
    15  
    16  Outputs define values that will be highlighted to the user
    17  when Terraform applies, and can be queried easily using the
    18  [output command](/cli/commands/output).
    19  
    20  Terraform knows a lot about the infrastructure it manages.
    21  Most resources have attributes associated with them, and
    22  outputs are a way to easily extract and query that information.
    23  
    24  This page assumes you are familiar with the
    25  [configuration syntax](/language/configuration-0-11/syntax)
    26  already.
    27  
    28  ## Example
    29  
    30  A simple output configuration looks like the following:
    31  
    32  ```hcl
    33  output "address" {
    34    value = "${aws_instance.db.public_dns}"
    35  }
    36  ```
    37  
    38  This will output a string value corresponding to the public
    39  DNS address of the Terraform-defined AWS instance named "db". It
    40  is possible to export complex data types like maps and lists as
    41  well:
    42  
    43  ```hcl
    44  output "addresses" {
    45    value = ["${aws_instance.web.*.public_dns}"]
    46  }
    47  ```
    48  
    49  ## Description
    50  
    51  The `output` block configures a single output variable. Multiple
    52  output variables can be configured with multiple output blocks.
    53  The `NAME` given to the output block is the name used to reference
    54  the output variable, and can include letters, numbers, underscores (`_`),
    55  and hyphens (`-`).
    56  
    57  Within the block (the `{ }`) is configuration for the output.
    58  These are the parameters that can be set:
    59  
    60  - `value` (required) - The value of the output. This can be a string, list, or
    61    map. This usually includes an interpolation since outputs that are static
    62    aren't usually useful.
    63  
    64  - `description` (optional) - A human-friendly description for the output. This
    65    is primarily for documentation for users using your Terraform configuration. A
    66    future version of Terraform will expose these descriptions as part of some
    67    Terraform CLI command.
    68  
    69  - `depends_on` (list of strings) - Explicit dependencies that this output has.
    70    These dependencies will be created before this output value is processed. The
    71    dependencies are in the format of `TYPE.NAME`, for example `aws_instance.web`.
    72  
    73  - `sensitive` (optional, boolean) - See below.
    74  
    75  ## Syntax
    76  
    77  The full syntax is:
    78  
    79  ```text
    80  output NAME {
    81    value = VALUE
    82  }
    83  ```
    84  
    85  ## Sensitive Outputs
    86  
    87  Outputs can be marked as containing sensitive material by setting the
    88  `sensitive` attribute to `true`, like this:
    89  
    90  ```hcl
    91  output "sensitive" {
    92    sensitive = true
    93    value     = VALUE
    94  }
    95  ```
    96  
    97  When outputs are displayed on-screen following a `terraform apply` or
    98  `terraform refresh`, sensitive outputs are redacted, with `<sensitive>`
    99  displayed in place of their value.
   100  
   101  ### Limitations of Sensitive Outputs
   102  
   103  - The values of sensitive outputs are still stored in the Terraform state, and
   104    available using the `terraform output` command, so cannot be relied on as a
   105    sole means of protecting values.
   106  
   107  - Sensitivity is not tracked internally, so if the output is interpolated in
   108    another module into a resource, the value will be displayed.