Skip to content

RotationSchedule

Source: src/AWS/SecretsManager/RotationSchedule.ts

Configures automatic rotation on a Secrets Manager secret (RotateSecret with a rotation Lambda + rules; CancelRotateSecret on delete).

Usually created for you by onSecretRotation, which also wires the invoke permission and the runtime handler — reach for the resource directly only when the rotation function is managed outside the current stack.

Rotate Every 30 Days

const schedule = yield* RotationSchedule("DbSecretRotation", {
secretId: secret.secretArn,
rotationLambdaArn: rotationFunctionArn,
rotationRules: { automaticallyAfter: "30 days" },
});

Cron Schedule with a Rotation Window

const schedule = yield* RotationSchedule("DbSecretRotation", {
secretId: secret.secretArn,
rotationLambdaArn: rotationFunctionArn,
rotationRules: {
scheduleExpression: "cron(0 8 1 * ? *)",
window: "3 hours",
},
});