AWS, Azure & GCP · Cloud across providers

How should you manage secrets in the cloud?

MediumsecretsvaultrotationUpdated Oct 2026
Quiz this track

Short answer

Store secrets in a managed secret store, grant access by identity, rotate them automatically and never commit them to code or images. Inject them at runtime or fetch them with short-lived credentials.

A secret is any credential that grants access: database passwords, API keys, private keys and tokens. The goal is to keep them out of source control and images, limit who and what can read them, and make rotation routine rather than an emergency.

Controls that matter

  • Use a managed store such as Secrets Manager, Key Vault or Secret Manager
  • Authorise access through workload identity, not shared static credentials
  • Encrypt secrets with a customer-managed key when required
  • Rotate automatically and support overlapping validity during rollout
  • Audit every read and alert on unusual access patterns
js
const secret = await secretsClient.getSecretValue({
  SecretId: "prod/db",
});
const { password } = JSON.parse(secret.SecretString);
Fetch the secret at runtime using the workload's role.

Environment variables are convenient but can leak through crash dumps, process listings and child processes. Fetching at runtime is better, and short-lived database credentials or token exchange remove long-lived secrets entirely.

If a secret is committed, rotate it first and clean history second. Removing the commit does not make the exposed value safe.

Follow-ups you should expect

Interviewers use these to check whether the first answer was understanding or memorisation.

  1. 1Why are environment variables not a complete secret strategy?
  2. 2How do you rotate a database password without downtime?
  3. 3What do you do first after a secret is committed to a repository?
  4. 4How does workload identity replace static credentials?

Say it in the interview

I keep secrets in a managed store, authorise access through workload identity, and fetch them at runtime instead of baking them into images or environment variables. Rotation is automated with overlapping validity so deploys do not break. If a secret leaks, I rotate it first and clean the repository second, because removing the commit does not revoke the value.

Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.

Related questions

Reading is step one

Now say it out loud.

Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live AWS, Azure & GCP mock interview and get scored feedback on depth, clarity and confidence.