Choosing a secrets manager is only the first step. This guide compares practical deployment patterns, provides a reusable rotation runbook, and includes adaptable Terraform, CI/CD, SDK, and access-policy templates for corporate cloud apps.
Overview
Secrets management covers the storage, access, use, rotation, and retirement of sensitive values such as database credentials, API tokens, signing keys, certificates, and third-party integration secrets. The objective is not simply to hide a password. A sound design limits who or what can access a secret, avoids placing credentials in source control or build logs, records access for investigation, and allows credentials to be changed without an avoidable service outage.
For most teams, the right provider is determined by operating context rather than by a universal feature ranking. A cloud-native application may prefer its cloud provider’s managed service because identity integration and regional deployment are already part of the platform. A company operating across clouds may prefer a central service such as HashiCorp Vault, provided it is prepared to run and secure another critical system. Smaller teams may use an open-source solution when they have the expertise to manage availability, encryption, upgrades, backups, and access control themselves.
| Option | Useful fit | Strengths to evaluate | Trade-offs to check |
|---|---|---|---|
| HashiCorp Vault | Multi-cloud or platform teams needing a central secrets layer | Flexible authentication, policy controls, secret engines, and dynamic credentials | Operational responsibility for deployment, availability, upgrades, recovery, and monitoring |
| AWS Secrets Manager | Applications primarily running on AWS | Integration with AWS identity and workload services, managed operation, and rotation workflows | Cloud-specific design, service permissions, network access, and provider-dependent integration choices |
| Azure Key Vault | Applications primarily running on Azure | Integration with Azure identity, key and certificate use cases, and managed service operation | Permission design, tenant and subscription boundaries, and dependence on Azure access paths |
| Google Secret Manager | Applications primarily running on Google Cloud | Integration with Google Cloud identity, versioned secrets, and managed operation | Workload identity design, project boundaries, and access configuration |
| Open-source or self-hosted tools | Teams with a clear reason to control the full deployment | Portability, inspectable implementation, and control over hosting choices | Patch management, high availability, backup security, incident response, and support ownership |
Compare each option against the same questions: How does an application authenticate without a long-lived bootstrap secret? Can access be scoped to one workload and environment? Are secret versions available for safe rollout and rollback? Can the service emit useful audit events? How will recovery work if the control plane, region, or identity provider is unavailable?
Checklist by scenario
When selecting a provider
- Map the trust boundary: list the clouds, accounts, subscriptions, projects, environments, and teams that need access.
- Classify the values: separate database passwords, API credentials, certificates, signing keys, and short-lived tokens. Their rotation and recovery procedures may differ.
- Choose an authentication method: prefer workload identity, OIDC, managed identities, or another short-lived mechanism over a permanent access key embedded in a deployment system.
- Define availability requirements: document whether applications need secrets at startup only or during every request, and decide how they behave if the manager is temporarily unavailable.
- Confirm audit and recovery needs: identify the events that must be retained and the people responsible for restoring access or secret data.
Scheduled rotation runbook
- Inventory the secret and record its owner, consuming applications, environment, provider path, rotation frequency, and emergency contact.
- Confirm that the replacement credential can be created without invalidating the current credential.
- Generate the new value through the provider or the upstream system. Do not create it in a developer workstation or print it in a pipeline log.
- Write the new value as a new secret version or staged credential, depending on the provider’s model.
- Update the consuming application or connection pool using a controlled deployment. If possible, allow the application to reload configuration without a full outage.
- Test authentication, authorization, critical API calls, background jobs, and health checks.
- Revoke the old credential only after successful validation and an agreed observation period.
- Record the change, validation evidence, revocation time, and any follow-up work.
Emergency rotation after suspected compromise
- Declare an incident and identify the exact secret, likely exposure path, affected environments, and time window.
- Preserve relevant logs and restrict access to the incident team without delaying containment.
- Revoke or disable the exposed value first when continued use presents material risk.
- Create a replacement using a trusted administrative path, then update applications and pipelines.
- Search source repositories, container layers, artifacts, tickets, chat messages, logs, and monitoring payloads for copies of the value. Treat every discovered copy as exposed.
- Review access logs for unexpected use and rotate related credentials if the original secret could have enabled lateral access.
- Validate service behavior and document the timeline, decisions, evidence, and preventive actions.
Onboarding a new cloud service
- Create a dedicated secret path and workload identity rather than reusing an application-wide credential.
- Grant read access only to the service, environment, and operation that require it.
- Put the secret reference—not the secret value—in Terraform variables, deployment manifests, and application configuration.
- Add a rotation owner, expiry or review date, alerting, and a tested failure procedure before production use.
Integration templates
The following patterns are deliberately provider-neutral. Adapt resource names, identity blocks, and policy syntax to the selected platform, then test them in a non-production account.
Terraform pattern
variable "database_secret_value" {
type = string
sensitive = true
}
resource "secret_store_entry" "database" {
name = "app/prod/database"
value = var.database_secret_value
labels = {
application = "orders-api"
environment = "production"
owner = "platform-team"
}
}
# Prefer a workload identity binding for the runtime service.
# Grant read access to this secret only; do not grant broad admin access.Marking a Terraform variable as sensitive helps reduce accidental display, but it does not make the value safe to commit or guarantee that it will never appear in state. Protect state storage, limit state access, use a controlled pipeline, and review plan output. Where supported, reference an existing secret or use a provider-specific secret resource designed for secure state handling.
CI/CD pattern
steps:
- name: authenticate
run: obtain-short-lived-identity
- name: fetch-secret-reference
run: secret-cli read app/${ENVIRONMENT}/database --output=runtime-file
- name: deploy
run: deploy-application --config=runtime-file
- name: cleanup
run: securely-remove-runtime-file
always: trueKeep secret values out of command-line arguments, cache directories, artifacts, test reports, and verbose debugging output. Prefer the pipeline platform’s secret-provider integration or inject values at the latest practical stage. The deployment identity should be able to read only the required paths in the target environment.
Application SDK pattern
client = SecretClient(identity=workload_identity())
secret = client.get("app/prod/database", version="current")
# Keep the value in memory where practical.
# Do not log it, return it in diagnostics, or include it in error messages.
database.connect(password=secret.value)Decide whether the application reads a secret at startup, on a timed refresh, or when a version changes. Include bounded retries and clear failure behavior. A refresh mechanism must not create a loop that repeatedly requests the secret manager during an outage.
Least-privilege policy shape
principal: workload/orders-api-production
allow:
- action: read_secret
resource: app/prod/database
conditions:
environment: production
identity_type: workload
source: approved-runtime
deny:
- action: write_secret
- action: delete_secret
- action: list_all_secretsUse the provider’s native policy language in production. Separate read, write, rotate, and administer permissions, and assign rotation rights to an automation identity or small operations group rather than to every application.
What to double-check
- Identity bootstrapping: verify that the application can obtain its first identity without a static secret hidden in an image, repository, or machine startup script.
- Environment separation: confirm that development, test, and production identities cannot read one another’s secrets by default.
- Secret propagation: check logs, traces, exception reports, browser responses, job artifacts, backups, and telemetry for accidental disclosure.
- Rotation compatibility: confirm that the upstream service supports overlapping credentials or a controlled maintenance window.
- Version behavior: document whether clients receive a fixed version, a current alias, or a cached value, and test rollback.
- Break-glass access: define a time-limited emergency path, approval requirements, logging, and post-incident review.
- Dependencies: test secret retrieval during deployment, autoscaling, failover, network restrictions, and provider maintenance scenarios.
For related implementation checks, connect this work to the environment variables versus secret managers guide, the API authentication comparison, and the production readiness checklist.
Common mistakes
- Using a secret manager as a dumping ground: organize paths, ownership, classifications, and lifecycle dates so unused values can be retired.
- Rotating without testing: changing a value on a schedule is not enough if the application cannot reload it or the external provider rejects the replacement.
- Confusing encoding with protection: Base64, URL encoding, and similar transformations do not secure a credential. Encryption and access control are separate requirements.
- Granting broad administrative access: a service that only reads one database credential should not be able to enumerate or delete every secret.
- Leaving old versions active: version history supports rollback, but obsolete credentials should be disabled or revoked according to the documented lifecycle.
- Ignoring non-production systems: test credentials can still provide access to real services when environments are connected or permissions are reused.
When to revisit
Review the provider comparison and integration templates at least every six months, before major seasonal planning cycles, and after a significant provider feature release. Recheck examples when SDKs, CLIs, deployment platforms, or recommended workload-identity methods change. Revisit rotation intervals when application architecture, compliance requirements, upstream provider limits, or incident findings change.
Use this short review sequence:
- Export an inventory of secrets, owners, consumers, permissions, versions, and last-rotation dates.
- Remove unused credentials and investigate secrets without an accountable owner.
- Test one scheduled rotation and one emergency rotation in a representative environment.
- Review audit events for unexpected reads, broad permissions, and failed authentication.
- Update Terraform, CI/CD, SDK, and policy templates, then record the date and reason for each change.
- Link the review to deployment planning, security exercises, and onboarding of new cloud services.
A secrets strategy is healthy when teams can answer three questions quickly: who can use each secret, how it will be replaced, and what happens if it is exposed. Make those answers part of the application’s normal delivery workflow rather than an emergency-only exercise.