Skip to main content
InterviewHubPRO
Section Overview
Q8

Question 8 of 50

Part 1: Terraform Core Architecture, HCL & Providers (1 - 15)

16%
Terraform & IaC (50 Qs)•Part 1: Terraform Core Architecture, HCL & Providers (1 - 15)

How do you protect sensitive secrets from leaking into plaintext Terraform State files?

senior LevelFormsCI/CD & DevOpsSystem Design

In Simple Words: Terraform state files store all resource attributes—including database passwords, TLS private keys, and API tokens—in plaintext JSON.

Protection strategy:

  1. Enable Server-Side Encryption (SSE-KMS) and strict IAM bucket policies on the S3 state bucket.
  2. Restrict state bucket access: Only CI/CD runner service accounts and platform admins should have read access.
  3. Mark sensitive variables with sensitive = true so values are redacted from terminal and CI logs.
  4. Delegate secrets generation to KMS or cloud secrets managers (AWS Secrets Manager / Vault) rather than generating plaintext passwords inside Terraform.