Prompt
What should I use for a secure app config and secrets setup?
Latest observation
Oct 25, 2026
OpenAI APIWeb search: off
A good secure setup usually means separating config from secrets, keeping secrets out of source control, and using a real secret manager rather than plain env files for anything sensitive.
Recommended approach
1) Use environment variables for non-sensitive config
Good for:
- feature flags
- app mode (
dev,staging,prod) - service URLs
- log levels
- timeouts
Keep these in deployment config, not in code.
2) Use a secrets manager for sensitive values
Best options:
- AWS Secrets Manager or SSM Parameter Store if you’re on AWS
- Google Secret Manager on GCP
- Azure Key Vault on Azure
- HashiCorp Vault for cloud-agnostic/self-managed setups
Store there:
- API keys
- database passwords
- OAuth client secrets
- signing keys
- encryption keys
3) Inject secrets at runtime
Pull secrets when the app starts, or via workload identity / IAM role / managed identity. Avoid baking secrets into:
- container images
- Git repos
- CI artifacts
4) Use local .env only for development
For dev only:
- keep
.envin.gitignore - commit a
.env.examplewith dummy values - never use
.envas your production secret store
5) Rotate and audit
- rotate secrets periodically
- use short-lived credentials where possible
- enable audit logs on secret access
- revoke unused secrets
Practical setup by environment
Local dev
.env+.env.example- secrets loaded from local secret manager if available
- no real production secrets on laptops
CI/CD
- store secrets in CI secret storage
- use OIDC/workload identity to fetch cloud secrets when possible
- avoid long-lived static credentials
Production
- use cloud secret manager + managed identity
- app reads secrets at runtime
- least-privilege access only
What not to do
- don’t hardcode secrets in code
- don’t commit
.envwith real values - don’t pass secrets through command-line args if avoidable
- don’t store secrets in plaintext config files
- don’t reuse one secret everywhere
Simple rule of thumb
- Config: env vars
- Secrets: secret manager
- Local dev:
.envonly - Prod: identity-based access to managed secrets
If you want, I can suggest a setup tailored to your stack, like Docker + Node, Kubernetes, AWS, or Python/Django.