Interview Prep/DevSecOps/Secrets management: Vault, External Secrets and SOPS

A security review finds the RDS master password in plain text in the Terraform state file in S3

IntermediateTroubleshootingSecrets management: Vault, External Secrets and SOPS
Answer

Likely causes → Terraform stores every attribute in state, including sensitive ones. sensitive = true only hides values from CLI output.

Diagnose →

terraform state pull | jq '.resources[] | select(.type=="aws_db_instance") | .instances[].attributes.password'

Fix → Rotate the password. Then remove it from Terraform entirely: manage_master_user_password = true makes RDS generate and store it in Secrets Manager. On Terraform 1.11+ with a recent provider you can also use write-only arguments such as password_wo, which are never persisted.

Prevent → Encrypt the state bucket with KMS, restrict s3:GetObject on state to CI roles, enable access logging, and treat state as a secret.

All DevSecOps questions Roadmap: Supply chain, secrets & identity

More on Secrets management: Vault, External Secrets and SOPS