How do you keep secrets out of the state file?
IntermediateProductionState and Backends in Production
Answer
Prefer not creating secrets in Terraform at all: let the service generate them (RDS manage_master_user_password = true), reference secret ARNs not values and let apps read from Secrets Manager. Where a secret value must pass through Terraform, use ephemeral resources and write-only arguments (1.10 and 1.11+). Otherwise assume the state contains it and lock the state down.
More on State and Backends in Production
Why should Terraform state never be committed to Git?BeginnerHow do you bootstrap the remote backend, given the bucket must exist before Terraform can use it?IntermediateWhat does a hardened S3 state bucket look like?IntermediateWhat is the minimum IAM permission set for the S3 backend?IntermediateHow do you move from DynamoDB locking to S3 native locking in a live fleet?IntermediateState was deleted or corrupted. How do you recover?Advanced