Skill 4.8.1

Sensitive variables and outputs

Key Concepts

Declaring a variable or output with sensitive = true makes Terraform show (sensitive value) instead of the value in plan and apply output and in terraform output. Values derived from sensitive values are treated as sensitive too, and an output that exposes a sensitive value must itself be marked sensitive. The sensitive() and nonsensitive() functions add or remove the marking.

The value is still written in plain text to state and plan files, and terraform output -json or -raw reveals it. Sensitive marking prevents accidental disclosure in logs; it is not encryption. Pair it with protected state and, for secrets, with ephemeral values.