Moving database passwords and API keys into AWS Secrets Manager removes them from code and config files, but it also creates one place where a single over-broad IAM permission can hand an attacker every credential the organisation owns. Secrets Manager is AWS's native store for machine credentials: it encrypts each secret with AWS KMS, versions it with staging labels, rotates it on a schedule and logs every retrieval in CloudTrail. How much protection that gives depends on choices that are easy to get wrong: which KMS key encrypts the secret, who can call GetSecretValue and PutResourcePolicy, how rotation is built and whether anyone watches the logs. This guide goes deep on Secrets Manager alone, covering its access model, privileged roles, rotation, logging and a hardening baseline. It is written for AWS platform, security and application teams.
This is an independent guide from NHI Mgmt Group, based on AWS's public documentation as of November 2026. It is not sponsored or reviewed by AWS. Product features change, so confirm settings against AWS's current documentation.
Key takeaways
- The KMS key is part of the access policy. The AWS managed key
aws/secretsmanageris free but cannot be used for cross-account access; a customer managed key lets you add a key policy andkms:ViaServiceconditions as a second, independent gate. PutResourcePolicyis a privilege escalation path. AWS warns that a principal holding it can rewrite a secret's resource policy and take full control, so requireBlockPublicPolicyand restrict the action to administrators.- Rotation is only safe if the application tolerates it. Choose single user or alternating users deliberately, cache secrets with the AWS caching components and test rotation before you schedule it, which can be as often as every four hours.
- Every read is an audit event.
GetSecretValueandBatchGetSecretValueappear in CloudTrail, and bulk reads across many secrets from one identity are among the clearest signals of compromise. - Metadata is not secret. Only the secret value is encrypted; names, descriptions, tags and rotation settings are not, so never put sensitive data in them.
How identity and access work in AWS Secrets Manager
A request to read a secret succeeds only if every applicable policy allows it. Treat each layer as a separate control rather than relying on one.
| Layer | What it controls | Key settings |
|---|---|---|
| Identity-based policy | Which secrets a role or user may read, write, rotate or delete | Scope Resource to secret ARNs or ARN prefixes; use secretsmanager:ResourceTag/<key> for attribute-based access control |
| Resource-based policy on the secret | Which principals (including other accounts) may act on this secret | Required for cross-account access; Secrets Manager uses automated reasoning (Zelkova) with BlockPublicPolicy to reject broad policies |
| KMS key policy | Who may decrypt the data key for the secret | kms:ViaService = secretsmanager.<region>.amazonaws.com; encryption context conditions on SecretARN |
| Network conditions | Which network paths may call the API | aws:SourceVpce or aws:SourceVpc with an interface VPC endpoint; AWS cautions against aws:SourceIp, which can break rotation functions and service calls |
| Organisation guardrails | Ceilings for every account | SCPs and RCPs. See the AWS Resource Control Policies and Data Perimeter Guide |
Encryption model. Secrets Manager uses envelope encryption: KMS generates a 256-bit AES data key for each new secret value, the value is encrypted outside KMS, and the encrypted data key is stored in the secret's metadata. Every GenerateDataKey and Decrypt call carries an encryption context of SecretARN and SecretVersionId, which you can use as a policy condition and to tie KMS events in CloudTrail to a specific secret. Only symmetric KMS keys are supported, and a customer managed key must be in the same account and Region as the secret.
| Choice | AWS managed key aws/secretsmanager | Customer managed key |
|---|---|---|
| Cost | No charge | KMS key charges apply |
| Key policy | Set by the service, cannot be changed; usable only through Secrets Manager | You write it, including kms:ViaService and context conditions |
| Cross-account access | Not possible | Required |
| Separation of duties | Any principal allowed by IAM to read the secret can decrypt it | Key administrators and secret readers can be different groups; denying kms:Decrypt blocks reads even if IAM allows GetSecretValue |
| When to use | Single-account workloads with simple needs | Shared, cross-account, regulated or high-value secrets |
Cross-account access needs four pieces. AWS documents a resource policy on the secret allowing the external principal, a customer managed key, a key policy granting that principal kms:Decrypt (plus kms:GenerateDataKey if it writes), and an identity policy in the other account allowing both the secret and the key. Verify the result with IAM Access Analyzer. See the IAM Access Analyzer Guide.
Admin roles and privileged access
AWS's own guidance for administrators is the SecretsManagerReadWrite and IAMFullAccess managed policies, the latter because enabling rotation creates roles, and it recommends against giving them to end users. Both are broader than most organisations need day to day, so split the work.
| Role | Typical actions | Guardrails |
|---|---|---|
| Secrets platform administrators | Create secrets, configure rotation and replication, manage resource policies | PIM-style elevation through IAM Identity Center permission sets; PutResourcePolicy only with secretsmanager:BlockPublicPolicy = true |
| Application owners | Put new values, trigger rotation for their own secrets | Tag-scoped or path-scoped ARNs; no access to other teams' secrets |
| Workload roles | GetSecretValue (and DescribeSecret) on named secrets | No ListSecrets beyond need, no wildcards on Resource, VPC endpoint condition |
| KMS key administrators | Manage key policies and rotation of the KMS key | No kms:Decrypt on secret keys; see the AWS KMS Security Guide |
| Security operations | DescribeSecret, ListSecrets, CloudTrail and Config read | No GetSecretValue; break-glass process for incident access |
Watch the destructive actions too. DeleteSecret schedules deletion after a recovery window of at least seven days, during which the secret is inaccessible but restorable; --force-delete-without-recovery deletes it permanently. Restrict force deletion with an SCP, and remember that a primary secret cannot be deleted while replicas exist. See the AWS Organizations and SCPs Guide and the AWS IAM Identity Center Guide.
Integrations, API tokens and service accounts
Secrets Manager mostly stores credentials for non-human identities, and the way workloads fetch them decides whether the secret stays secret.
- Caching components: AWS lists client-side caching for Java, Python, .NET, Go and Rust, the AWS Parameters and Secrets Lambda Extension, Secrets Manager in Amazon EKS and the AWS Workload Credentials Provider. Caching cuts API calls and cost, and lets applications pick up rotated values without redeploying.
- Containers and Kubernetes: fetch secrets at runtime with the workload's own IAM role rather than baking them into images or environment files. See the AWS Lambda Security Guide for function patterns.
- Managed secrets and managed rotation: some AWS services create and rotate secrets on your behalf (managed rotation, no Lambda function), and managed external secrets rotation updates credentials held by Secrets Manager partners. Prefer these where available: there is no rotation code for you to maintain.
- Rotation Lambda functions: the function is itself a privileged service identity. It needs to read and write the secret and change the password on the target database or service, and if it runs in a VPC it needs a route to Secrets Manager (interface endpoint or NAT) and to the target. For alternating users rotation it also reads a separate superuser secret.
- CI/CD pipelines: pipelines that create or update secrets should use OIDC federation, not stored access keys. See How to set up workload identity federation for GitHub Actions to AWS.
- The bootstrap problem: the workload still needs an identity to call Secrets Manager. On AWS that should be an instance profile, task role, IRSA or Pod Identity role, never a long-lived key stored next to the application. See the Secrets Zero Problem Guide.
- CLI hygiene: AWS notes that command shells can log commands and expose recently entered values, so avoid passing secret values as CLI arguments on shared hosts.
Rotation in practice
Each secret keeps versions tracked by staging labels: AWSCURRENT (returned by default, always present), AWSPREVIOUS and AWSPENDING (used during rotation). A Lambda rotation function is called four times with the steps create_secret, set_secret, test_secret and finish_secret; if any step fails, Secrets Manager retries the whole rotation during the rotation window.
| Strategy | How it works | Use when | Watch for |
|---|---|---|---|
| Managed rotation | The owning service rotates; no Lambda | The service supports it | Confirm which applications read the secret before enabling |
| Single user | Changes the password of one user in place | Most cases; ad hoc or interactive users | A short window where the database has the new password but clients hold the old one; use retries with exponential backoff and jitter |
| Alternating users | Clones the user on first rotation, then alternates which user's password changes | High-availability applications; table-owner and table-user models | Needs a superuser secret; permission changes to the original user must be repeated on the clone |
Rollout order: enable rotation in a non-production account, confirm every consumer uses a caching client or re-reads on authentication failure, run a manual rotation and watch for RotationFailed, then set the schedule. Rollback is to move the AWSCURRENT label back to the previous version with UpdateSecretVersionStage while the cause is fixed. Unlabelled versions are deprecated and removed when a secret has more than 100 versions, so do not rely on old versions as a backup. See the Secrets Rotation Runbook Template.
Logging and detection
| Event or source | What it shows | Detection idea |
|---|---|---|
GetSecretValue, BatchGetSecretValue (CloudTrail) | Who read which secret, from where | One identity reading many secrets in a short period; reads from new IPs, unusual user agents or outside the workload's VPC endpoint |
PutResourcePolicy, DeleteResourcePolicy | Changes to who can reach a secret | Any change outside the pipeline; principals from unknown accounts |
RotationStarted, RotationSucceeded, RotationFailed, RotationAbandoned | Rotation health | Failures and secrets past their expected rotation date |
DeleteSecret, StartSecretVersionDelete, EndSecretVersionDelete | Deletion activity | Mass deletion (sabotage or ransom); access attempts during the recovery window |
ReplicationStarted, ReplicationSucceeded, ReplicationFailed | Copies to other Regions | Replication to a Region you do not operate in |
KMS Decrypt and GenerateDataKey with encryption context | Key use tied to a SecretARN | Correlate with Secrets Manager events; direct decrypt attempts outside the service |
AWS also lists CloudWatch, AWS Config compliance rules and Amazon GuardDuty for monitoring secrets, and recommends a CloudWatch alarm on access attempts to secrets scheduled for deletion to find forgotten consumers. Map detections to T1555.006 Cloud Secrets Management Stores and T1078.004 Cloud Accounts. See the AWS CloudTrail Guide and the AWS Config Guide.
Metrics that show it is working:
- Percentage of secrets with automatic rotation enabled and a successful rotation inside the policy period.
- Number of identity policies granting
secretsmanager:GetSecretValueon*(target: zero outside break-glass). - Percentage of high-value and cross-account secrets on customer managed keys with
kms:ViaServiceconditions. - Secrets not read in 90 days (candidates for deletion) and hardcoded credentials found by code scanning per month.
- Mean time to detect a bulk-read pattern in exercises.
Hardening baseline
- Inventory first. List every secret with its owner tag, KMS key, rotation status, last accessed date and resource policy, and scan code and pipelines for hardcoded credentials (AWS points to the CodeGuru Reviewer secrets detector and Amazon Q). See the Secret Sprawl Measurement Guide.
- Name and tag for access control. Adopt a path convention such as
prod/payments/and owner and environment tags, so policies can be scoped by ARN prefix or tag. - Choose keys. Customer managed keys with
kms:ViaServicefor production and shared secrets; optionally deny use ofaws/secretsmanagerin production accounts, as AWS's IAM examples show. - Scope workload access. One role per workload,
GetSecretValueon its own secrets only, with anaws:SourceVpcecondition where the workload runs in a VPC. Test that rotation functions and AWS services still work before enforcing network conditions. - Guard resource policies. Require
BlockPublicPolicyon everyPutResourcePolicygrant, alert on resource policy changes, and review cross-account access with IAM Access Analyzer. - Enable rotation in rings. Non-production, then low-risk production, then the rest, with caching clients deployed first and rollback by staging label documented.
- Replicate deliberately. Replicate only secrets needed for multi-Region recovery, and include the replica Regions in your monitoring scope.
- Protect deletion. SCP deny on
ForceDeleteWithoutRecoveryoutside break-glass; alarms on deletion and on access to deleted secrets. - Keep secrets out of metadata. Names, descriptions and tags are not encrypted.
Common misconfigurations
- Wildcard read access: a workload role with
GetSecretValueon*turns one compromised host into a full credential dump. In the AI Agent Retail Card Theft Campaign 2026, attackers dumped every Secrets Manager secret they could reach, 46 in one case, and used them to reach the payment database. - Uncontrolled
PutResourcePolicy: developers or pipelines able to edit resource policies can grant themselves or an external account access, which AWS explicitly flags as escalation. - Rotation enabled before consumers are ready: applications that read the secret once at start-up fail after the first rotation, and teams respond by disabling rotation permanently.
- Secrets copied out after retrieval: values written to environment variables, logs or build artefacts escape all the controls above.
- Cross-account sharing on the wrong key: teams discover that
aws/secretsmanagercannot be shared and then copy the secret into the other account, creating two unrotated copies. - Encryption keys stored beside the data they protect: an application encryption key in the same reachable store as the credentials to the encrypted data defeats the point of encrypting it.
Framework mapping
| Secrets Manager control | NIST SP 800-53 Rev. 5 | NIST CSF 2.0 |
|---|---|---|
| Least-privilege secret and key policies | AC-6 Least Privilege; AC-3 Access Enforcement | PR.AA-05 |
| Automatic rotation and versioning | IA-5 Authenticator Management | PR.AA-01 |
| KMS envelope encryption | SC-28 Protection of Information at Rest; SC-12 Cryptographic Key Establishment and Management | PR.DS-01 |
| CloudTrail logging of reads and changes | AU-2 Event Logging; AU-6 Audit Record Review, Analysis, and Reporting | DE.CM-03 |
In ISO/IEC 27001:2022 terms this supports Annex A 5.17 (authentication information), 8.24 (use of cryptography) and 8.15 (logging).
Practitioner checklist
- Every secret has an owner tag, an environment path and a documented consumer list.
- No identity policy grants
GetSecretValueon*; workload roles are scoped to their own secrets. - Production and cross-account secrets use customer managed keys with
kms:ViaService. PutResourcePolicyallowed only withBlockPublicPolicy, and only to administrators.- Interface VPC endpoint in use, with
aws:SourceVpceconditions tested against rotation functions. - Rotation enabled with the right strategy, caching clients in place and staging-label rollback documented.
- CloudTrail alerts for bulk reads, resource policy changes, rotation failures and deletions.
- Force deletion blocked by SCP outside break-glass.
- Code and pipelines scanned for hardcoded credentials, with findings migrated into Secrets Manager.
- No sensitive data in secret names, descriptions or tags.
Standards and references
- AWS Secrets Manager User Guide: Best practices
- AWS Secrets Manager User Guide: Secret encryption and decryption
- AWS Secrets Manager User Guide: Cross-account access
- AWS Secrets Manager User Guide: Rotation strategies
- AWS Secrets Manager User Guide: What's in a secret
- AWS Secrets Manager User Guide: CloudTrail entries
- MITRE ATT&CK: Cloud Secrets Management Stores
- NIST: SP 800-53 Rev. 5
Related NHI Mgmt Group resources: Cloud Secrets Managers Guide · Secrets Management Guide · AWS KMS Security Guide · AWS Security Guide