Prompt
How do I centralize secrets for dev, staging, and prod without making developer access painful?
Latest observation
A good pattern is to centralize secret storage, but keep access and delivery environment-scoped and developer-friendly.
Recommended approach
1) Use one secrets manager, separate by environment
Store secrets in a single platform like:
- AWS Secrets Manager / SSM Parameter Store
- HashiCorp Vault
- GCP Secret Manager
- Azure Key Vault
- Doppler / 1Password Secrets Automation / Infisical
Organize secrets by:
dev/…staging/…prod/…
This gives you a single source of truth while keeping environments isolated.
2) Give developers default access to dev only
To avoid painful workflows:
- Developers can read dev secrets directly when needed
- They do not get standing access to staging/prod secrets
- Use just-in-time access or a controlled approval flow for higher environments
Typical access model:
- Dev: open to engineering team
- Staging: restricted to on-call / release engineers / via approval
- Prod: very restricted, usually only through CI/CD or break-glass access
This prevents devs from needing to juggle credentials constantly while still protecting production.
3) Prefer machine identity over shared human secrets
Avoid distributing long-lived “dev/staging/prod passwords” to people.
Instead:
- Developers authenticate using SSO + MFA
- Workloads authenticate using cloud IAM roles, workload identity, or short-lived tokens
- CI/CD uses service identities to fetch secrets at deploy/runtime
This makes access easier and more secure:
- no shared vault password
- no manual copying of secrets into laptops
- fewer leaks in
.envfiles and chat
4) Use local development defaults
To reduce friction, let developers run locally with:
.env.examplechecked into git- a script like
make envortool secrets pull dev - auto-loading from the secrets manager into a local
.envfile - stub/mock credentials for non-sensitive integrations when possible
Common pattern:
- first-time setup: login with SSO
secrets pull devwrites local env vars- app runs exactly like staging/prod, but with dev credentials
5) Keep prod secrets out of developer laptops when possible
For production:
- inject secrets at runtime in Kubernetes, ECS, serverless, etc.
- let CI/CD deploy using an identity that can read prod secrets
- developers should rarely need direct prod secret values
If a developer needs to debug prod:
- use read-only observability access first
- if secret access is truly necessary, use short-lived elevation with audit logging
6) Namespace secrets by app + environment
Use a structure like:
myapp/dev/db/urlmyapp/dev/payments/api_keymyapp/staging/db/urlmyapp/prod/db/url
This helps with:
- least privilege
- easy rotation
- clear auditing
- avoiding accidental cross-env use
7) Add guardrails, not manual process
Useful guardrails:
- secret scanning in git
- CI checks preventing prod secret references in dev configs
- audit logs for secret reads
- automatic expiration/rotation
- deny-by-default IAM policies
- break-glass access for emergencies
A practical developer-friendly workflow
- Developer logs in with SSO
- Runs:
secrets loginsecrets pull dev
- Local
.envis generated from the dev namespace - App runs against dev resources or local mocks
- Staging/prod secrets are only fetched by deploy pipelines or limited roles
This keeps the experience smooth without exposing everything to everyone.
If you want the simplest viable setup
A good baseline for many teams is:
- 1 secret manager
- 3 namespaces: dev/staging/prod
- SSO + MFA
- developers can access dev
- CI/CD accesses staging/prod
- short-lived credentials only
- local pull command for dev
Rule of thumb
If a developer needs production secrets often, the system is probably too coupled to secrets. Prefer:
- better observability
- environment parity
- feature flags
- service-to-service auth
- masked sample data
If you want, I can also sketch:
- a recommended IAM policy model
- a Vault/AWS/GCP example layout
- or a developer CLI workflow for pulling secrets safely.