Certopolis

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: AWSCURRENT moves only in finishSecret.
  • Believing single user rotation drops open connections: it does not, though new calls can be denied briefly.

Written from these sources

Try 3 questions on this

Pick an answer to see why each option is right or wrong.

  1. An Amazon RDS for MySQL DB instance was created with its master user password managed in AWS Secrets Manager, so the account holds a secret that Amazon RDS created for it. The team also created its own secret for the application's database user on the same instance. Both secrets must rotate every 30 days, and a rotation Lambda function may be deployed only where a secret cannot rotate without one. Which action should the SysOps administrator take to meet these requirements?

    Right. In the game that’s Renown for your Security and Compliance building.

    Not that one: D is right. In the game your Security and Compliance building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    The secret the team created for the application user is an ordinary secret, and every ordinary secret rotates through a Lambda rotation function. So exactly one function is deployed, for the application user's secret.

    Written from docs.aws.amazon.com/secretsmanager/latest/userguide/rotating-secrets.html

  2. A database administrator signs in interactively to an Amazon RDS for PostgreSQL database as the user dba_kim, whose password is stored in an AWS Secrets Manager secret. Auditors require the password to change every 30 days and each person to have exactly one database login. Rotation will use a Lambda function from the Secrets Manager templates. Which solution will meet these requirements?

    Right. In the game that’s Renown for your Security and Compliance building.

    Not that one: A is right. In the game your Security and Compliance building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    It is also the strategy AWS recommends for interactive or ad hoc users. The brief window during rotation when a new connection might be refused does not matter for someone signing in by hand, who can simply retry.

    Written from docs.aws.amazon.com/secretsmanager/latest/userguide/rotation-strategy.html

  3. Last night a Lambda rotation of an AWS Secrets Manager secret stopped partway through, after the function had stored a new value but before it promoted that value. The SysOps administrator lists the secret's versions to find the one the rotation created. The secret holds a current version, the version before it, and the new one. Which of the following identifies the version that the interrupted rotation created?

    Right. In the game that’s Renown for your Security and Compliance building.

    Not that one: D is right. In the game your Security and Compliance building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    Because this rotation stopped before that last step, the new value is still the version labeled AWSPENDING.

    Written from docs.aws.amazon.com/secretsmanager/latest/userguide/whats-in-a-secret.html

Ask for something