AWS Certified CloudOps Engineer – Associate
Secrets Manager rotation: managed, single user, alternating
The AWS Secrets Manager User Guide describes two main forms of rotation. Managed rotation, used for secrets that a service such as Amazon RDS manages, needs no Lambda function. Other secrets rotate through a Lambda function in four steps, with either the single user or the alternating users strategy, and staging labels mark each version.
Managed rotation or rotation by Lambda function?
With managed rotation, the owning service configures and runs the rotation, and no Lambda function is involved. Amazon RDS, Aurora, DocumentDB and Redshift offer it for master or admin credentials. You change its schedule on the managed secret itself.
Managed rotation typically completes within one minute, and a secret can be rotated as often as every four hours. Schedules are entered in UTC.
Every other kind of secret uses rotation by Lambda function, where the function updates both the secret and the database or service. AWS recommends that applications use a database user with minimal privileges and not the master user.
Single user or alternating users?
Single user rotation updates the credentials of one user in one secret. It is the simplest strategy and suits most cases. AWS recommends it for interactive or one-time (ad hoc) users. Open connections are not dropped, but for a short time between the password change and the secret update the database may deny calls with the rotated credentials.
Alternating users rotation keeps two users in one secret. The first rotation clones the original user, and each later rotation updates whichever user was not updated last. An application that reads the secret during rotation still gets valid credentials, so it suits applications that need high availability.
Because most users cannot clone themselves, alternating users needs the credentials of a superuser in a separate secret. If you later change the original user's permissions, change the clone's too.
What are the four steps and the staging labels?
A rotation function runs createSecret, setSecret, testSecret and finishSecret. createSecret stores a new value as a version labeled AWSPENDING. setSecret changes the credential in the database to match it. testSecret uses the AWSPENDING version to access the database.
finishSecret moves the AWSCURRENT label to the new version, and Secrets Manager puts AWSPREVIOUS on the old one so the last known good version is kept.
If rotation stops before the last step, AWSCURRENT still points at the old value and the new value sits in AWSPENDING. To see where each label is, call describe-secret and read VersionIdsToStages. Secrets Manager only lets the rotation function rotate the secret directly; it cannot call another Lambda function to do it.
Where the exam catches people
- Looking for a Lambda rotation function on a secret that Amazon RDS manages: managed rotation does not use one.
- Choosing alternating users for an interactive user: AWS recommends single user rotation for interactive or ad hoc users.
- Setting up alternating users without a superuser secret: the function needs superuser credentials to clone the user.
- Believing a half-finished rotation changed what applications read:
AWSCURRENTmoves only infinishSecret. - Believing single user rotation drops open connections: it does not, though new calls can be denied briefly.