Skip to main content



This is the SST v0.x Constructs doc. SST v1 is now released. If you are using v1, see the v1 Constructs doc. If you are looking to upgrade to v1, check out the migration steps.

The Cron construct is a higher level CDK construct that makes it easy to create a cron job. You can create a cron job by handler function and specifying the schedule it needs to run on. Internally this construct uses a EventBridge Rule.


new Cron(scope: Construct, id: string, props: CronProps)



Using the rate expression

import { Cron } from "@serverless-stack/resources";

new Cron(this, "Cron", {
schedule: "rate(1 minute)",
job: "src/lambda.main",

Using the cron expression

new Cron(this, "Cron", {
schedule: "cron(15 10 * * ? *)",
job: "src/lambda.main",

Using Duration

import { Duration } from "aws-cdk-lib";

new Cron(this, "Cron", {
schedule: Duration.days(1),
job: "src/lambda.main",

Using CronOptions

new Cron(this, "Cron", {
schedule: { minute: "0", hour: "4" },
job: "src/lambda.main",

Giving the cron job some permissions

Allow the function to access S3.

const cron = new Cron(this, "Cron", {
schedule: "rate(1 minute)",
job: "src/lambda.main",


Configuring the job

Configure the internally created CDK Event Target.

import { RuleTargetInput } from "aws-cdk-lib/aws-events";

new Cron(this, "Cron", {
schedule: "rate(1 minute)",
job: {
function: "src/lambda.main",
jobProps: {
event: RuleTargetInput.fromObject({
key: "value"


An instance of Cron contains the following properties.


Type :

The internally created CDK EventBridge Rule instance.


Type : Function

The internally created Function instance that'll be run on schedule.


An instance of Queue contains the following methods.


attachPermissions(permissions: Permissions)


Attaches the given list of permissions to the jobFunction. This allows the function to access other AWS resources.

Internally calls Function.attachPermissions.



Type : FunctionDefinition | CronJobProps, defaults to undefined

Takes FunctionDefinition or CronJobProps object used to create the function for the cron job.


Type : string | cdk.Duration |

The schedule for the cron job. Can be specified as a string. The string format takes a rate expression.

"rate(_Value Unit_)"

// For example, every 5 minutes
"rate(5 minutes)"

Or as a cron expression.

"cron(Minutes Hours Day-of-month Month Day-of-week Year)"

// For example, 10:15 AM (UTC) every day
"cron(15 10 * * ? *)"

You can also use the cdk.Duration as an alternative to defining the rate expression.

import { Duration } from "aws-cdk-lib";

// Repeat every 5 minutes

// As cdk.Duration

// The equivalent rate expression
"rate(5 minutes)"

Similarly, you can specify the cron expression using

// 10:15 AM (UTC) every day

// As
{ minute: "15", hour: "10" }

// The equivalent cron expression
"cron(15 10 * * ? *)"


Type :, defaults to undefined

Or optionally pass in a CDK EventBridge RuleProps. This allows you to override the default settings this construct uses internally to create the events rule.



Type : FunctionDefinition

A FunctionDefinition object that'll be used to create the job function for the cron.


Type :, defaults to undefined

Or optionally pass in a CDK LambdaFunctionProps. This allows you to override the default settings this construct uses internally to create the job.