Rotate an AWS Secrets Manager secret on a schedule with a Lambda rotation function, understand AWSPENDING and AWSCURRENT, and how RDS managed rotation differs from a secret you rotate yourself.

AWS Secrets Manager rotation changes a secret value on a schedule so a leaked or aged password does not live forever. The work is done by a Lambda function that Secrets Manager invokes, and the secret versions are labeled AWSPENDING, AWSCURRENT and AWSPREVIOUS.
A common failure mode is a client that read the password once at startup and never asked again, or a rotation function that updated the secret but not the database. This guide walks through the stages, RDS managed rotation, and a generic Lambda, then states clearly what Encore does and does not do with rotation.
On each rotation, Secrets Manager invokes the Lambda with a step name. The usual sequence is: create a new version labeled AWSPENDING, set that value on the database or API, test a login with it, then move AWSCURRENT to the new version and leave the old one as AWSPREVIOUS. If a step fails, AWSCURRENT stays on the last good value.
For a generic secret, you provide the function and grant Secrets Manager permission to invoke it, and grant the function permission to read and update the secret and to change the protected resource. The rotation function template list is the starting point for RDS, DocumentDB and some other stores.
Turn on a rotation schedule only after you have run the function once by hand against a non-production secret and confirmed that clients reconnect. AWS lets you choose the interval; pick a window you are willing to watch.
Best fit: secrets whose consumers can re-read the value, and a rotation function you have tested.
For supported RDS and Aurora setups, Secrets Manager can use a managed rotation function. You still have to create the secret in the form the integration expects, grant the right IAM, and make sure every application user of that password re-reads it. Alternating-user rotation uses two credentials so the old user can stay valid until the cutover finishes; single-user rotation changes one password in place and is harder on long-lived connections.
If Encore provisioned the RDS instance, do not assume an AWS-managed rotation function is configured for the database users in use. Rotate application secrets through Encore's secret settings, or verify any AWS rotation against those users yourself.
Encore has a secrets API: you declare a var secrets struct, set values with encore secret set or in the platform dashboard, and production values are not stored in the repository, so an AI coding agent working in the repo cannot read those from git. A local override in .secrets.local.cue is a file on disk and is readable. On deploy to your own AWS or GCP account, Encore replicates the values into a secrets manager in your account and injects them into the service. Encore provisions an IAM role for the service, or a service account on GCP.
Encore does not document that it will run a Secrets Manager rotation Lambda for those values. To rotate an Encore secret, set a new value for the environment and follow the secrets documentation for how the process receives it. If you manage a separate secret in AWS that Encore does not inject, AWS rotation applies to that secret alone.
A coding agent can add the secrets struct and the code that uses it; you set and rotate the values yourself.
Best fit: application secrets declared in code, kept out of the repository, and injected in your own cloud, with rotation done through Encore's secret settings unless you have a separate AWS-managed secret.
Use AWS managed rotation for supported RDS credentials that your applications re-read. Use a rotation Lambda you own for other secrets. Use Encore secrets for values your service should declare in code and keep out of the git repository, and rotate those through Encore rather than assuming a Lambda will change them.
Secrets Manager invokes a rotation Lambda on a schedule. The function creates a new secret value as AWSPENDING, updates the protected service, tests a login, then moves the AWSCURRENT label to the new version. The previous value remains as AWSPREVIOUS so in-flight clients can finish.
For supported RDS and Aurora engines, you can turn on managed rotation and let AWS use a provided rotation function, as described in the Secrets Manager RDS documentation. The instance and the secret have to be set up for that integration; a generic secret uses a rotation function you own instead.
A client should fetch the secret when it connects, or at least when a login fails, rather than caching a password forever. During rotation there is a window where AWSPENDING and AWSCURRENT exist together. If the app keeps a password from process start, it can fail until it is restarted or it re-reads the secret.
Encore stores secret values you set with encore secret set or the Secrets Manager in the dashboard, and on deploy it replicates them into a secrets manager in your AWS or GCP account and injects them into the service. It does not document a Secrets Manager rotation Lambda that you can treat as managed rotation. Rotate values in the Encore dashboard or CLI and redeploy or restart as the docs require, or use AWS rotation on secrets you manage yourself.
Deploy to your cloud on AWS and Google Cloud
without managing infrastructure
Encore lets developers and agents define application infrastructure directly in code, then automatically provisions it from local development to production in your AWS or GCP account.