Interview Prep/Terraform/State Backends and Workspaces

Security asks, "who can see our secrets in Terraform state?" What do you answer?

AdvancedScenarioState Backends and Workspaces
Answer

Situation read → State stores resource attributes in plain text, including DB passwords and private keys.

What I'd do →

  1. Treat state read access as equal to secret access and restrict it to CI and a few admins.
  2. Encrypt at rest with KMS and enforce TLS in transit.
  3. Reduce secrets in state: RDS manage_master_user_password, ephemeral values and write-only arguments on Terraform 1.10/1.11+, secrets fetched at runtime by apps.
  4. Audit access with CloudTrail.

Why → sensitive = true only hides values in CLI output; it never removes them from state.

Interview tip → This question tests whether you know "sensitive" is redaction, not protection.

All Terraform questions Roadmap: Terraform in production

More on State Backends and Workspaces