Prompt
How do I store API keys and database passwords in one place?
Latest observation
Oct 25, 2026
OpenAI APIWeb search: off
The safest way is to use a secrets manager or environment variables, rather than putting keys/passwords directly in code.
Common options
-
Environment variables
- Good for small apps and local development.
- Example:
API_KEY=...,DB_PASSWORD=... - Your app reads them at runtime.
-
Secrets manager
- Best for production.
- Examples:
- AWS Secrets Manager
- HashiCorp Vault
- Azure Key Vault
- Google Secret Manager
- 1Password Secrets Automation
- Lets you store, rotate, and control access to secrets centrally.
-
.envfiles- Convenient for development only.
- Keep them out of git using
.gitignore. - Don’t use them as the main production storage.
Best practice
- Do not hardcode secrets in source code
- Do not commit secrets to Git
- Use least-privilege access
- Rotate secrets regularly
- Separate secrets by environment: dev, staging, prod
Simple setup pattern
- Store secrets in a secrets manager or
.env - Load them into your app at startup
- Access them through config variables, not direct literals
If you tell me your stack (Python, Node, Docker, AWS, etc.), I can show you the best way to do it there.