Prompt

How do I store and rotate API keys without putting them in config files?

Technology / Cybersecurity1 observationLast seen Oct 25, 2026

Latest observation

Oct 25, 2026OpenAI APIWeb search: off

The usual pattern is: don’t store API keys in app config files at all. Keep them in a secret store or environment variable system, and rotate them through the provider or an automation workflow.

Good options for storage

1) Environment variables

Best for simple apps and local development.

  • Store the key in the runtime environment, not in the repo:
    • Linux/macOS shell: export API_KEY=...
    • Docker/Kubernetes: inject as env vars from secrets
  • Access it in code via the environment.
  • Keep .env files out of version control.

Pros: simple, widely supported
Cons: not ideal for large-scale rotation/auditing by itself

2) Secret managers

Best for production.

Examples:

  • AWS Secrets Manager
  • Azure Key Vault
  • Google Secret Manager
  • HashiCorp Vault
  • Doppler, 1Password Secrets Automation, etc.

These provide:

  • encrypted storage
  • access control
  • auditing
  • versioning
  • rotation hooks

Your app fetches the secret at startup or on demand using its identity/role.

3) Platform-native secret systems

If you run on a platform, use its built-in system:

  • Kubernetes Secrets + External Secrets Operator or CSI driver
  • AWS ECS task secrets / IAM roles
  • GitHub Actions Secrets / GitLab CI Variables / CircleCI contexts
  • Cloud Run / App Engine / Azure App Service app settings

How to rotate them safely

Rotation pattern

  1. Create a new key
  2. Deploy app to accept both old and new keys temporarily if needed
  3. Update secret store with the new key
  4. Restart or reload services if they cache secrets
  5. Revoke the old key after confirming the new one works

This avoids downtime.

Make rotation easier

  • Use a secret manager that supports versions
  • Load secrets at runtime instead of baking them into images
  • Keep keys short-lived when possible
  • Prefer OAuth tokens, service accounts, or workload identities over long-lived static API keys

Practical recommendations

If you’re starting out

  • Use environment variables for local dev
  • Use a managed secret store in production
  • Never commit secrets to git
  • Add secret scanning in CI

If you want best security

  • Use a secret manager + workload identity
  • Rotate automatically on a schedule
  • Limit permissions of each key
  • Log access to secrets, but never log the secret value itself

Example workflow

  • App reads API_KEY from environment
  • Production environment injects it from AWS Secrets Manager
  • A scheduled job generates a new key monthly
  • Secret Manager version is updated
  • App instances refresh/restart
  • Old key is revoked after a grace period

What to avoid

  • Hardcoding keys in source code
  • Putting them in checked-in config files
  • Sending secrets through plain-text emails or chat
  • Logging secrets in application logs
  • Using one shared key for everything if you can avoid it

If you want, I can show:

  • a Node/Python/Go example for reading secrets safely, or
  • a rotation setup for AWS/GCP/Azure/Kubernetes.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.