Migrate secrets from environment variables in a Git repo to AWS Secrets Manager. How?

BeginnerScenarioMigrations
Answer

Situation read → Two goals: get secrets out of Git, and assume they're compromised because they were in Git.

What I'd do →

  1. Create the secrets in Secrets Manager (via Terraform with values supplied out of band, or the CLI).
aws secretsmanager create-secret --name prod/api/db --secret-string '{"username":"app","password":"..."}'
  1. Deliver to apps: External Secrets Operator on Kubernetes syncing into native Secrets, or the Secrets Store CSI driver.
  2. Grant read access per app with IRSA or Pod Identity, scoped to that app's secret ARNs.
  3. Rotate every secret that lived in Git; history still contains them.
  4. Remove from the repo, add gitleaks to pre-commit and CI so they don't come back.

Why → Moving a leaked secret into a vault doesn't un-leak it; rotation is mandatory.

Interview tip → Say "rotate them all" before the interviewer has to ask.

All Real-World Interview questions Roadmap: Interview readiness

More on Migrations