Bitzu

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

Single choice

What does sensitive = true on a variable do?

  1. Redacts the value in CLI output but it still reaches state
  2. Encrypts the value inside the state file
  3. Removes the value from the state file
  4. 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.

Select all that apply

Which statements are true?

  1. Sensitive values are still stored in the state file
  2. terraform output -raw prints a sensitive output in plain text
  3. Expressions that use a sensitive value are also shown as sensitive
  4. sensitive = true encrypts the value in state
  5. 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.

True or false

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.

Download on the App StoreGet it on Google Play

More Terraform Associate 004 topics in this module