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
Which command prints all root module output values?
- terraform output
- terraform validate
- terraform fmt
- 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.
Which statements about sensitive outputs are true?
- The all-outputs list shows <sensitive> instead of the value
- terraform output NAME prints the value in plain text
- -json output redacts the value
- The value is still stored in state
- 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: 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.
