secret

Any value that grants access, such as a password, access token or private key, and must be kept out of code and version control.

A leaked secret lets whoever finds it act with its access until it is rotated.

In more detail

Secrets belong in a secret manager or an encrypted file, never in plain code, configuration, logs or a Git repository. If one leaks, rotate it; deleting the copy is not enough.

Examples

Ansible keeps secrets in Vault-encrypted files and hides them from output with no_log: true.
Twelve-factor apps read secrets from the environment and never keep them in the codebase; the open source test catches secrets in version control. A proposed revision of the manifesto replaces long-lived secrets with short-lived workload identity.
Committing a token to Git leaks it into every clone, even after the file is untracked.
In Next.js only variables prefixed NEXT_PUBLIC_ reach the browser; keep secrets unprefixed and import them only from server-only modules.
Never log a password or put a token in a span attribute or metric label.
.env files with passwords belong in .gitignore.
Audit policies log access to Kubernetes Secrets at Metadata level so the secret value itself never lands in logs.
sk-live-4d1f-demo, the fake payment key used throughout module two
In Terraform, secrets must never go into committed .tfvars files. Supply them through environment variables or a secret manager, and remember that anything a resource uses ends up in state unless it is ephemeral or write-only. Rotate any secret that appears in a state snapshot someone should not have seen.
In this course: A real payment client needs a secret key, which is one more reason tests use a double instead of calling it. Store secrets in a secret manager or the pipeline's secret store, never in test code.

Related terms

Taught in

References

Certification courses