Terraform Associate 004 ยท Dependencies, validation and sensitive data
Sensitive values and state exposure
sensitive = true for variables and outputs, what it hides in CLI output, why values still reach the state file, protecting state (4h).
Key points
- sensitive = true on a variable or output redacts the value in CLI and HCP Terraform output, and anything derived from it.
- It does not keep the value out of state or plan files: those hold it in plain text, and terraform output -raw or -json prints it.
- Protect state with a remote backend, encryption at rest, access control and audit logs, and never commit it to Git.
Source: https://developer.hashicorp.com/terraform/language/manage-sensitive-data
Practice questions
What does sensitive = true on a variable do?
- Redacts the value in CLI output but it still reaches state
- Encrypts the value inside the state file
- Removes the value from the state file
- Prevents the value from being set on the command line
Show answer
Answer: A. Redacts the value in CLI output but it still reaches state
It redacts the value in CLI output, but the value is still stored in state and plan files.
Which statements are true?
- Sensitive values are still stored in the state file
- terraform output -raw prints a sensitive output in plain text
- Expressions that use a sensitive value are also shown as sensitive
- sensitive = true encrypts the value in state
- Marked values are absent from plan files
Show answer
Answer: A. Sensitive values are still stored in the state file, B. terraform output -raw prints a sensitive output in plain text, C. Expressions that use a sensitive value are also shown as sensitive
Sensitive values remain in state, terraform output with -raw or -json prints them, and expressions derived from sensitive values are redacted too. sensitive does not encrypt state.
Marking an output sensitive = true keeps its value out of the state file.
Show answer
Answer: False
False. It only redacts display; the value is still written to state.
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.
