Store and use secrets securely
Framework question: How do you manage identities for people and machines?
- Risk if not established
- High
- Framework verified
- 23 Oct 2026
AWS Well-Architected Framework — SEC02-BP03 Store and use secrets securely
Executive summary
Why this practice matters
Handle workload secrets in three steps: remove them where an identity-based alternative exists, replace long-lived secrets with short-lived ones where possible, and store and rotate whatever remains in a purpose-built secrets service. Keep secrets out of code, and watch how they're accessed.
Business impact
- Stops secrets leaking through source code, logs or shared documents.
- Limits how long a leaked secret stays useful.
- Makes it possible to rotate a compromised secret quickly.
- Shows who accessed which secret, and when.
Assign
Accountable and responsible roles
Responsibilities are held separately from roles, so accountability type and typical roles are stated explicitly.
| Responsibility | Accountability type | Typical roles |
|---|---|---|
Use secrets securely in workloads Retrieve secrets at runtime from the secrets service and remove them from code. Typical roles: Software Engineer, DevOps Engineer, Software Engineer, DevOps Engineer | responsible | Software EngineerDevOps EngineerSoftware Engineer, DevOps Engineer |
Provide secrets management and scanning Run the secrets service, rotation and repository scanning. Typical roles: Cloud / Platform Engineer, Security Engineer, Cloud Platform Engineer, Security Engineer | responsible | Cloud / Platform EngineerSecurity EngineerCloud Platform Engineer, Security Engineer |
Respond to secret exposure Respond to leaked secrets and unusual secret access. Typical roles: Security Operations / Incident Response, Security Operations | responsible | Security Operations / Incident ResponseSecurity Operations |
Assessment
Assessment and evidence state
States describe how far the practice has moved from intent to something continuously validated.
- 0
Not Assessed
Secrets handling has not been reviewed.
Indicators
- No secrets inventory exists.
- 1
Not Implemented
Secrets live in code, configuration or shared documents.
Indicators
- Passwords in config files.
- No scanning.
- 2
Partially Implemented
A secrets service is used for some workloads, but rotation and scanning are inconsistent.
Indicators
- Manual rotation, rarely done.
- Legacy secrets outside the service.
- 3
Implemented
Secrets are removed where possible, stored in a secrets service, rotated and kept out of code.
Indicators
- Pre-commit or pipeline scanning.
- Automatic rotation for most secrets.
- 4
Continuously Validated
Secret access is monitored and rotation and scanning are continuously verified.
Indicators
- Unusual secret access alerts.
- Overdue rotations tracked.
Assessment dimensions
Storage
Practice-specificCode / config · Mixed · Secrets service only
Rotation
Practice-specificNever · Manual · Automatic
Leak prevention
Practice-specificNone · Periodic scan · Pre-commit and pipeline
Access monitoring
Practice-specificNone · Logged · Alerted
Caution
A secrets service in use doesn't prove secrets aren't elsewhere. Look for scanning of code and artefacts, rotation, and monitoring of secret access.
Standard
What you should be able to demonstrate
Statements a reviewer should be able to confirm from evidence, not from intent.
- Secrets each workload needs are known and listed.
- Secrets are removed or replaced with temporary credentials wherever possible.
- Remaining secrets live in a purpose-built secrets service and are retrieved at runtime.
- Rotation is automatic where the secret type supports it.
- Code and artefacts are scanned so secrets never reach repositories.
- Access to secrets is monitored for unusual use.
Trade-offs to hold in view
- Automatic rotation needs applications that handle changing credentials gracefully; test this before enabling it.
- Retrieving secrets at runtime adds a dependency on the secrets service, so plan for caching and availability.
- Pre-commit scanning can produce false positives that slow developers; tune rules over time.
Assess
Questions to ask
Each question exposes the difference between an intention and an operating practice.
- discovery
Which secrets does this workload depend on, and where is each stored?
You can't protect secrets you haven't found.
Usually asked by: Software Engineer, DevOps Engineer
- challenge
Which of these secrets could be removed entirely by using a role instead?
The safest secret is one that doesn't exist.
Usually asked by: Security Architect
- evidence
Show the latest secret-scanning results and the rotation status of your most sensitive secrets.
Proves leak prevention and rotation actually run.
Usually asked by: Security Engineer
- executive
If a production database password leaked today, how quickly could we change it without an outage?
Frames secrets management as incident response readiness.
Usually asked by: Security Leader, Service Owner
Evidence
Required and expected evidence
Reusable evidence definitions held once in the evidence library and referenced by every practice that relies on them. Each links to what good evidence looks like and to worked examples.
Credential & Secrets Inventory
A current inventory of the long-term credentials and secrets a workload or organisation relies on: what each is, what uses it, where it is stored, who owns it, whether it rotates, when it was last rotated and audited, and why a temporary alternative isn't used.
Use the Credential & Secrets Inventory as primary evidence of where secrets are stored, how they rotate, and scanning results.
Minimum expected content
- Scope: workloads, accounts and environments covered
- Each long-term credential or secret: type (access key, password, API token, certificate, etc.) and purpose
- Consuming identity or system
- Storage location (secrets service, parameter store, other)
- Owner
- Rotation method (automatic/manual), interval, and last rotation date
- Last audit or access-review date
- Justification where a temporary credential is not used, and the planned replacement
- Detection of secrets in code repositories or artefacts
- Exceptions with owner and expiry
Anti-patterns
- Access keys for machines where roles could be used
- Secrets in source code, environment files or wikis
- A spreadsheet nobody reconciles
- Rotation 'planned' but never done
- Credentials shared between people or systems
- No owner for service credentials
Review: Reconcile at least quarterly against real configuration, and immediately after any suspected credential exposure.
Standard Security Control Baseline / IaC Template
Version-controlled, reusable security-control definitions and infrastructure-as-code templates that deploy approved baseline controls consistently across workloads, accounts or environments, with automated tests and guardrails.
Use the Standard Security Control Baseline / IaC Template to show secret retrieval and scanning are built into standard pipelines.
Minimum expected content
- Baseline/control package identity, version and owner
- Security control objectives implemented by the baseline
- Infrastructure-as-code, policy-as-code or configuration definitions
- Intended deployment scope/accounts/environments/workload classes
- Required inputs and permitted configuration variation
- Automated unit/static/policy/security tests
- Deployment pipeline and approval/change controls
- Guardrails preventing or detecting unsafe configuration
- Self-service consumption path for workload teams where applicable
- Drift/conformance monitoring after deployment
- Rollback/recovery and backup/version-retention approach
- Supported/deprecated versions and migration expectations
- Change history and review date
Anti-patterns
- A wiki page describes the baseline but teams implement it manually
- A central security team deploys every control by request
- Templates exist but have no automated security or policy tests
- Workload teams fork templates and cannot consume upstream security fixes
- Baseline success is measured by template deployment, not resulting control conformance
- Emergency manual changes are never reconciled back into code
- No supported-version or migration policy exists
Review: Review with every material baseline/template version and at a defined security-engineering cadence; retain version history and supported versions.
Diagnosis
Common evidence gaps
Secrets in code
Database passwords and API tokens sit in source code or environment files.
No rotation
Secrets are stored securely but never changed.
No scanning
Nothing checks commits or build artefacts for secrets.
Unknown secrets
Nobody knows which secrets a workload depends on.
Implementation
Implementation guidance
Identify the secrets
List the secrets each workload needs: database credentials, API tokens, keys and certificates.
Remove and replace first
Remove secrets by using roles and identity-based access; replace long-lived ones with temporary credentials where possible.
Store in a secrets service
Store remaining secrets in a secrets service and retrieve them at runtime, never embedding them.
Rotate automatically
Turn on automatic rotation wherever the secret type allows it.
Prevent leaks
Scan commits and build artefacts for secrets before they reach the repository.
Monitor access
Alert on unusual secret access or attempts to delete secrets.
Measure
Measurements
- Percentage of secrets held in a secrets service.
- Percentage of secrets rotating automatically.
- Number of secrets found in code or artefacts.
- Number of secrets past their rotation interval.
Related
Outcomes and practices
Business outcomes
Practices