Interview Prep/DevSecOps/Secrets and Identity Management

A team stores database passwords in a `.env` file committed to a private repo. How do you migrate them out?

BeginnerScenarioSecrets and Identity Management
Answer

Situation read → Private does not mean safe. Every clone, fork, laptop and CI cache now holds production credentials.

What I'd do →

  1. Treat every value in the file as exposed and plan rotation, not just removal.
  2. Create the secrets in a store (AWS Secrets Manager, Vault, Azure Key Vault): aws secretsmanager create-secret --name prod/orders/db --secret-string file://db.json.
  3. Change the app or deployment to read from the store (External Secrets Operator, CSI driver or SDK call).
  4. Rotate each credential, then delete .env and add it to .gitignore; commit a .env.example with placeholders.
  5. Add gitleaks in pre-commit and CI so it does not come back.

Why → Moving the file without rotating leaves the old values valid in git history forever.

Interview tip → Always say "rotate first, clean history second".

All DevSecOps questions Roadmap: Supply chain, secrets & identity

More on Secrets and Identity Management