Skip to main content
← Back to articles

Secrets Management with Infisical and Vault Patterns

Injecting secrets at runtime, rotating credentials, and keeping repos free of config leakage.

Nestlancer Editorial

Share

Secrets Management with Infisical and Vault Patterns

Secrets in .env files committed by accident end careers. Runtime injection via Infisical, Vault, or cloud secret managers keeps credentials rotatable and auditable.

Never in git

  • Block commits with gitleaks or trufflehog in pre-commit and CI
  • .env.example documents keys, never values
  • CI fetches short-lived tokens from OIDC—not long-lived PATs in GitHub secrets

Injection at runtime

// Bootstrap loads secrets before NestFactory.create
const dbUrl = await secrets.get('DATABASE_URL');
process.env.DATABASE_URL = dbUrl;

Kubernetes: use CSI secret store driver or init containers that mount files read by the app.

Rotation playbook

Secret typeRotation cadence
Database passwords90 days, dual-credential window
API keys (third party)On vendor prompt + quarterly audit
JWT signing keys6 months with JWKS overlap

Automate rotation where APIs support it; manual runbooks for the rest.

Least privilege

Service accounts get only secrets for their namespace. Media worker does not read payment API keys.

Secrets management is hygiene, not heroics—boring defaults prevent exciting incidents.

Comments

Loading comments…

Related posts