Interview Prep/Terraform/Resources Variables and Expressions

A module takes a database password and exposes the connection string as an output. How do you stop them leaking into plan output?

BeginnerScenarioResources Variables and Expressions
Answer

Situation read → Values are printed in plan/apply logs by default.

What I'd do →

  1. Mark the variable sensitive = true.
  2. Mark any output derived from it sensitive = true (Terraform will require it).
  3. Read it explicitly with terraform output -raw db_url when needed.

Why → Sensitive values are redacted in the CLI output, but they are still stored in plain text in the state file. This is redaction, not encryption.

Interview tip → Always follow up with "so state itself must be encrypted and access-controlled".

All Terraform questions Roadmap: Terraform

More on Resources Variables and Expressions