Interview Prep/DevSecOps/Container and IaC Security

Terraform state contains database passwords in plain text. How do you handle it?

IntermediateScenarioContainer and IaC Security
Answer

Situation read → State stores resource attributes, including sensitive ones, even if marked sensitive = true in outputs.

What I'd do →

  1. Use a remote backend with encryption and versioning: S3 with SSE-KMS, bucket policy restricting principals, DynamoDB or S3 native lockfile.
  2. Restrict read access to state to the CI role and a few admins.
  3. Avoid creating secrets in Terraform: use manage_master_user_password = true for RDS or reference Secrets Manager.
  4. Enable ephemeral resources/values on Terraform 1.10+ where supported.
  5. Audit access through CloudTrail data events.

Why → State is as sensitive as the secrets inside it.

Interview tip → Note that sensitive = true hides CLI output only.

All DevSecOps questions Roadmap: Policy as code

More on Container and IaC Security