Bitzu

Terraform Associate 004 ยท Configuration building blocks

Output values

output blocks, sensitive outputs, terraform output command and -json, root vs child module outputs (4c).

Key points

  • An output "NAME" { value = ... } block exposes a value after apply.
  • In a child module, outputs are returned to the caller as module.NAME.OUTPUT; only root module outputs are printed by terraform output.
  • Use -json for machine-readable data and -raw for a bare string, number or bool. sensitive = true hides the value in plan and apply output and in the list view, but not when it is requested by name.

Source: https://developer.hashicorp.com/terraform/cli/commands/output

Practice questions

Single choice

Which command prints all root module output values?

  1. terraform output
  2. terraform validate
  3. terraform fmt
  4. terraform init
Show answer

Answer: A. terraform output

terraform output with no arguments lists every root output. terraform show prints state or a plan, and the others do not display outputs.

Select all that apply

Which statements about sensitive outputs are true?

  1. The all-outputs list shows <sensitive> instead of the value
  2. terraform output NAME prints the value in plain text
  3. -json output redacts the value
  4. The value is still stored in state
  5. The value is encrypted in the state file
Show answer

Answer: A. The all-outputs list shows <sensitive> instead of the value, B. terraform output NAME prints the value in plain text, D. The value is still stored in state

The list view shows <sensitive>, but asking for the name prints the real value, and -json shows it too. It remains in state, so sensitive is not encryption.

True or false

True or false: setting sensitive = true on an output prevents anyone with access to the CLI from reading its value.

Show answer

Answer: False

False. It only redacts the value in some displays; requesting the output by name or using -json shows it.

Practice 8 questions on this topic in Bitzu

Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.

Download on the App StoreGet it on Google Play

More Terraform Associate 004 topics in this module