How do you handle sensitive values like passwords in Terraform without exposing them in state?

Medium Topic: Terraform May 24, 2026

Terraform state files contain sensitive values in plaintext — this is a known limitation. Mitigations:

  • Mark as sensitive: sensitive = true on variables and outputs prevents them from appearing in CLI output.
  • Avoid storing in state: Use AWS Secrets Manager or Vault to generate and store secrets externally. Reference via data source or environment variable.
  • Encrypt state: S3 backend with server-side encryption (SSE-KMS).
  • Restrict access: The S3 bucket containing state should have strict IAM policies — only CI/CD roles should have access.
← Previous What are Terraform data sources and how do... Next → How do you implement Terraform in a CI/CD...

Practice Similar Questions

Back to Terraform Topics