Interview Prep/Terraform/Secrets Provisioners and Policy as Code

How do you generate and manage the master password for a new RDS instance?

IntermediateScenarioSecrets Provisioners and Policy as Code
Answer

Situation read → You don't want a human choosing or seeing the password.

What I'd do →

  1. Prefer AWS-managed master credentials: manage_master_user_password = true stores and rotates it in Secrets Manager.
  2. Applications read it from Secrets Manager at runtime via IAM.
resource "aws_db_instance" "main" {
  engine                      = "postgres"
  username                    = "app_admin"
  manage_master_user_password = true
}

Why → No password in code, tfvars or state, and rotation is automatic.

Interview tip → The alternative random_password puts the value in state.

All Terraform questions

More on Secrets Provisioners and Policy as Code