Automatic Rotation
Change passwords on a schedule without downtime or human hands.
Long-lived credentials are risky: the longer a password exists, the more places it might have leaked. Rotation replaces a secret regularly, for example every 30 days.
How it works
Secrets Manager keeps versions of each secret, labeled with staging labels:
AWSCURRENT: the value apps should useAWSPENDING: the new value being prepared during rotationAWSPREVIOUS: the last value, kept as a fallback
A rotation Lambda function runs four steps: create a new value, set it in the target system (e.g.
change the database password), test that it works, and finish by moving AWSCURRENT to the new
version.
- 1createSecret
New value as AWSPENDING
- 2setSecret
Apply to the database
- 3testSecret
Log in with it
- 4finishSecret
Promote to AWSCURRENT
Getting it for free (almost)
- RDS, Aurora, Redshift, and DocumentDB have managed rotation. With RDS's
--manage-master-user-password, rotation is handled entirely for you. - For other databases and services, AWS provides rotation function templates.
- For third-party API keys, write a rotation function that calls the provider's "create key" API.
Apps that always fetch AWSCURRENT (and don't cache forever) pick up rotated values automatically. That's
what makes zero-downtime rotation possible.
Key takeaways
- Rotation replaces secrets on a schedule to limit the damage from leaks.
- Staging labels (AWSCURRENT, AWSPENDING, AWSPREVIOUS) make rotation safe.
- RDS and Aurora offer managed rotation, and templates cover many other cases.
Check your understanding
Pick an answer to see the explanation.
1. Which staging label should applications read?