Skip to content
← All articlesCloud & DevOps

Secrets Management for Cloud Apps: A Practical Guide

How to store API keys, passwords and certificates safely in cloud apps, what to avoid, and what to demand from an outsourced DevOps team.

Almost every application depends on secrets: database passwords, payment gateway keys, third-party API tokens, signing keys and certificates. How those values are stored and shared is one of the most common weak points in software projects, and it becomes more important when several teams, including an outsourced one, touch the same codebase.

This guide is for CTOs, founders and product managers who want to know what good looks like, without needing to read vendor documentation.

What counts as a secret

A secret is any value that would let someone act as your system or access your data if it leaked. Typical examples:

  • Database and cache credentials
  • API keys for payments, email, SMS, maps and AI services
  • OAuth client secrets and signing keys for tokens
  • Private keys and TLS certificates
  • Cloud provider access keys
  • Webhook signing secrets

Ordinary configuration, such as a feature name or a public URL, is not secret and can live in normal config files.

Where secrets leak most often

Most breaches of this kind are mundane, not sophisticated:

  • Committed to Git. A key pasted into a config file “just for testing” stays in the history even after it is deleted.
  • Shared in chat or email. Messages are searchable, forwarded and kept for years.
  • Baked into mobile apps or front-end bundles. Anything shipped to a user’s device can be extracted. A key in a mobile app is not a secret.
  • Printed in logs. Debug output and error reports often capture request headers and connection strings.
  • Shared accounts. One login used by everyone means you cannot tell who did what, or revoke one person’s access cleanly.
  • Never rotated. A key created three years ago and known to every former developer is a standing risk.

The core principles

  1. Keep secrets out of source code. Code references a secret by name; the value is injected at runtime.
  2. Use a dedicated secrets store. Managed options include AWS Secrets Manager, Azure Key Vault, Google Secret Manager and HashiCorp Vault. They provide encryption, access control and an audit trail.
  3. Give each environment its own secrets. Development, staging and production should never share credentials.
  4. Apply least privilege. Each service and each person gets access only to what they need.
  5. Rotate regularly and after any suspected exposure. Design the application so that rotation does not require a code change.
  6. Prefer short-lived credentials. Where the platform supports it, workloads can obtain temporary credentials through roles rather than holding long-lived keys.
  7. Audit access. You should be able to answer who read or changed a secret, and when.

Options compared

Approach Good for Watch out for
Environment variables set by the platform Small apps, simple setups Easy to leak through logs or crash dumps; manual updates
Cloud secrets manager Most production workloads Needs IAM set up correctly; small per-secret cost
HashiCorp Vault or similar Larger or multi-cloud estates Operational effort to run and secure it
Encrypted files in Git (for example SOPS) Teams wanting config in version control Key management for the encryption key still matters
Kubernetes Secrets Workloads already on Kubernetes Stored base64-encoded by default, not encrypted; enable encryption at rest and tight access rules

Secrets in CI/CD pipelines

Build pipelines are a favourite target because they hold powerful credentials. Good practice includes:

  • Store pipeline secrets in the CI platform’s encrypted secret storage, never in the repository.
  • Use identity federation (such as OpenID Connect between the pipeline and your cloud) so deployments do not need stored long-lived cloud keys.
  • Limit which branches and which people can trigger jobs that access production secrets.
  • Mask secrets in build output and avoid printing environment variables.
  • Run automated secret scanning on every commit and pull request so mistakes are caught early.

If you are setting up pipelines, our post on CI/CD with GitHub Actions covers the workflow side.

What to do when a secret leaks

Have the steps written down before you need them:

  1. Revoke or rotate the exposed secret immediately; do not wait to investigate first.
  2. Check logs from the provider for use of the credential during the exposure window.
  3. Remove the value from code and history where practical, but treat it as compromised regardless.
  4. Identify why it leaked and fix the process, not just the instance.
  5. Record the event in your incident log. See incident management for live applications for a response structure.

Questions to ask an outsourced team

Secrets handling is a good test of a vendor’s engineering maturity. Ask:

  • Where will production secrets be stored, and who will have access?
  • Will our team own the cloud accounts and secrets store, or the vendor?
  • How do developers run the app locally without real production credentials?
  • Is secret scanning enabled in the repositories and pipelines?
  • What is the rotation plan, and what happens when someone leaves the project?
  • How are secrets handed over at the end of the engagement?

Developers should never need production secrets for day-to-day work. If a vendor asks for them in a spreadsheet or a chat message, treat that as a warning sign.

A simple starting checklist

  • Secret scanning enabled on all repositories
  • No secrets in code, config files committed to Git, or build logs
  • A managed secrets store in use for production
  • Separate credentials for each environment
  • Named accounts for every person, with multi-factor authentication
  • A documented rotation schedule and leak response plan
  • Access removed promptly when people leave the project

Getting help

Good secrets management is mostly discipline and setup done once, then maintained. Our cloud and DevOps services include secure pipeline design, secrets store setup and access reviews for teams across the US, UK, Europe, the Middle East and Australia. To review your current approach, get in touch.

Let’s build what’s next.

Tell us about your platform, your product idea or the systems you want to modernise. Someone from our Chennai engineering team will get back to you personally.