Storing Secrets with Secrets Manager and Parameter Store
This lesson explains how AWS Secrets Manager and Parameter Store store database passwords, API keys and tokens securely, removing a common audit finding of secrets in code, AMIs or environment files.
Learning outcomes
After completing this lesson, you will be able to:
- Describe Secrets Manager features.
- Explain the steps of secret rotation.
- Choose between Secrets Manager and SecureString parameters.
AWS Secrets Manager
Secrets Manager stores secrets as encrypted values (JSON key-value pairs or text, up to 64 KB) using a KMS key, controls access with IAM and resource-based policies (for cross-account access), and records access in CloudTrail. Secrets have versions with staging labels AWSCURRENT, AWSPENDING and AWSPREVIOUS. Replica secrets copy a secret to other Regions for multi-Region applications and DR. Applications retrieve secrets at runtime with GetSecretValue, ideally through caching clients or the Lambda Parameters and Secrets extension; ECS and EKS inject secrets into containers, and CloudFormation uses dynamic references.
Rotation
Rotation changes a secret on a schedule (as often as every four hours) using a Lambda rotation function that runs four steps: createSecret, setSecret (change the password in the database), testSecret and finishSecret (move AWSCURRENT). For RDS, Aurora, Redshift and DocumentDB credentials, AWS provides rotation function templates, and managed rotation is available for secrets that services such as RDS create themselves (for example the master password when Manage master credentials in AWS Secrets Manager is selected). The alternating users strategy rotates between two database users so connections never fail during rotation. A rotation function in a VPC needs network access both to the database and to the Secrets Manager endpoint (an interface endpoint or NAT), and its role needs permission for the secret and its KMS key; missing endpoints are the most common rotation failure, visible in the function's CloudWatch logs.
The following diagram shows the four rotation steps.

A rotation cycle
Parameter Store SecureString
Parameter Store SecureString parameters are encrypted with KMS and suit configuration values and secrets that do not need rotation. Parameter Store is cheaper (the standard tier is free), supports hierarchies and versions, and can reference Secrets Manager secrets through the /aws/reference/secretsmanager/ path, but has no built-in rotation, no cross-account resource policies (except for advanced-tier parameter sharing with AWS RAM) and no replica secrets. The following table compares the two services.
Secrets Manager or Parameter Store?
Removing hard-coded passwords
A security review finds a database password in an application's environment file baked into the AMI. The team creates a Secrets Manager secret with the RDS rotation template using the alternating users strategy and a 30-day schedule, places the rotation function in the database's VPC with a Secrets Manager interface endpoint, grants the application's instance role secretsmanager:GetSecretValue on the secret and kms:Decrypt on its key, and changes the application to read the secret at start-up with a caching client. The password is rotated immediately, invalidating the leaked value, and the AMI is rebuilt without the file.
Which rotation strategy avoids connection failures while a password changes?
Show answer
Alternating users rotation.
Exam Tips
Remember for the exam
- Secrets Manager rotates secrets with Lambda functions; Parameter Store does not rotate.
- Rotation functions in a VPC need routes to the database and the Secrets Manager endpoint.
- Alternating users rotation avoids connection failures during rotation.
- Replica secrets support multi-Region applications.
- Use SecureString for non-rotating configuration values at lower cost.