Skip to content
v2.274.0

Amazon EventBridge Scheduler Construct Library ​

Amazon EventBridge Scheduler is a feature from Amazon EventBridge that allows you to create, run, and manage scheduled tasks at scale. With EventBridge Scheduler, you can schedule millions of one-time or recurring tasks across various AWS services without provisioning or managing underlying infrastructure.

  1. Schedule: A schedule is the main resource you create, configure, and manage using Amazon EventBridge Scheduler. Every schedule has a schedule expression that determines when, and with what frequency, the schedule runs. EventBridge Scheduler supports three types of schedules: rate, cron, and one-time schedules. When you create a schedule, you configure a target for the schedule to invoke.
  2. Target: A target is an API operation that EventBridge Scheduler calls on your behalf every time your schedule runs. EventBridge Scheduler supports two types of targets: templated targets and universal targets. Templated targets invoke common API operations across a core groups of services. For example, EventBridge Scheduler supports templated targets for invoking AWS Lambda Function or starting execution of Step Functions state machine. For API operations that are not supported by templated targets you can use customizable universal targets. Universal targets support calling more than 6,000 API operations across over 270 AWS services.
  3. Schedule Group: A schedule group is an Amazon EventBridge Scheduler resource that you use to organize your schedules. Your AWS account comes with a default scheduler group. A new schedule will always be added to a scheduling group. If you do not provide a scheduling group to add to, it will be added to the default scheduling group. You can create up to 500 schedule groups in your AWS account. Groups can be used to organize the schedules logically, access the schedule metrics and manage permissions at group granularity (see details below). Schedule groups support tagging. With EventBridge Scheduler, you apply tags to schedule groups, not to individual schedules to organize your resources.

Defining a schedule ​

ts
declare const fn: lambda.Function;

const target = new targets.LambdaInvoke(fn, {
    input: ScheduleTargetInput.fromObject({
        "payload": "useful",
    }),
});

const schedule = new Schedule(this, 'Schedule', {
    schedule: ScheduleExpression.rate(Duration.minutes(10)),
    target,
    description: 'This is a test schedule that invokes a lambda function every 10 minutes.',
});
python
# fn: lambda.Function


target = targets.LambdaInvoke(fn,
    input=ScheduleTargetInput.from_object({
        "payload": "useful"
    })
)

schedule = Schedule(self, "Schedule",
    schedule=ScheduleExpression.rate(Duration.minutes(10)),
    target=target,
    description="This is a test schedule that invokes a lambda function every 10 minutes."
)
java
Function fn;


LambdaInvoke target = LambdaInvoke.Builder.create(fn)
        .input(ScheduleTargetInput.fromObject(Map.of(
                "payload", "useful")))
        .build();

Schedule schedule = Schedule.Builder.create(this, "Schedule")
        .schedule(ScheduleExpression.rate(Duration.minutes(10)))
        .target(target)
        .description("This is a test schedule that invokes a lambda function every 10 minutes.")
        .build();
csharp
Function fn;


var target = new LambdaInvoke(fn, new ScheduleTargetBaseProps {
    Input = ScheduleTargetInput.FromObject(new Dictionary<string, string> {
        { "payload", "useful" }
    })
});

var schedule = new Schedule(this, "Schedule", new ScheduleProps {
    Schedule = ScheduleExpression.Rate(Duration.Minutes(10)),
    Target = target,
    Description = "This is a test schedule that invokes a lambda function every 10 minutes."
});
go
var fn Function


target := targets.NewLambdaInvoke(fn, &ScheduleTargetBaseProps{
	Input: awscdk.ScheduleTargetInput_FromObject(map[string]*string{
		"payload": jsii.String("useful"),
	}),
})

schedule := awscdk.NewSchedule(this, jsii.String("Schedule"), &ScheduleProps{
	Schedule: awscdk.ScheduleExpression_Rate(awscdk.Duration_Minutes(jsii.Number(10))),
	Target: Target,
	Description: jsii.String("This is a test schedule that invokes a lambda function every 10 minutes."),
})

Schedule Expressions ​

You can choose from three schedule types when configuring your schedule: rate-based, cron-based, and one-time schedules.

Both rate-based and cron-based schedules are recurring schedules. You can configure each recurring schedule type using a schedule expression.

For cron-based schedules you can specify a time zone in which EventBridge Scheduler evaluates the expression.

ts
declare const target: targets.LambdaInvoke;

const rateBasedSchedule = new Schedule(this, 'Schedule', {
    schedule: ScheduleExpression.rate(Duration.minutes(10)),
    target,
    description: 'This is a test rate-based schedule',
});

const cronBasedSchedule = new Schedule(this, 'Schedule', {
    schedule: ScheduleExpression.cron({
        minute: '0',
        hour: '23',
        day: '20',
        month: '11',
        timeZone: TimeZone.AMERICA_NEW_YORK,
    }),
    target,
    description: 'This is a test cron-based schedule that will run at 11:00 PM, on day 20 of the month, only in November in New York timezone',
});
python
# target: targets.LambdaInvoke


rate_based_schedule = Schedule(self, "Schedule",
    schedule=ScheduleExpression.rate(Duration.minutes(10)),
    target=target,
    description="This is a test rate-based schedule"
)

cron_based_schedule = Schedule(self, "Schedule",
    schedule=ScheduleExpression.cron(
        minute="0",
        hour="23",
        day="20",
        month="11",
        time_zone=TimeZone.AMERICA_NEW_YORK
    ),
    target=target,
    description="This is a test cron-based schedule that will run at 11:00 PM, on day 20 of the month, only in November in New York timezone"
)
java
LambdaInvoke target;


Schedule rateBasedSchedule = Schedule.Builder.create(this, "Schedule")
        .schedule(ScheduleExpression.rate(Duration.minutes(10)))
        .target(target)
        .description("This is a test rate-based schedule")
        .build();

Schedule cronBasedSchedule = Schedule.Builder.create(this, "Schedule")
        .schedule(ScheduleExpression.cron(CronOptionsWithTimezone.builder()
                .minute("0")
                .hour("23")
                .day("20")
                .month("11")
                .timeZone(TimeZone.AMERICA_NEW_YORK)
                .build()))
        .target(target)
        .description("This is a test cron-based schedule that will run at 11:00 PM, on day 20 of the month, only in November in New York timezone")
        .build();
csharp
LambdaInvoke target;


var rateBasedSchedule = new Schedule(this, "Schedule", new ScheduleProps {
    Schedule = ScheduleExpression.Rate(Duration.Minutes(10)),
    Target = target,
    Description = "This is a test rate-based schedule"
});

var cronBasedSchedule = new Schedule(this, "Schedule", new ScheduleProps {
    Schedule = ScheduleExpression.Cron(new CronOptionsWithTimezone {
        Minute = "0",
        Hour = "23",
        Day = "20",
        Month = "11",
        TimeZone = TimeZone.AMERICA_NEW_YORK
    }),
    Target = target,
    Description = "This is a test cron-based schedule that will run at 11:00 PM, on day 20 of the month, only in November in New York timezone"
});
go
var target LambdaInvoke


rateBasedSchedule := awscdk.NewSchedule(this, jsii.String("Schedule"), &ScheduleProps{
	Schedule: awscdk.ScheduleExpression_Rate(awscdk.Duration_Minutes(jsii.Number(10))),
	Target: Target,
	Description: jsii.String("This is a test rate-based schedule"),
})

cronBasedSchedule := awscdk.NewSchedule(this, jsii.String("Schedule"), &ScheduleProps{
	Schedule: awscdk.ScheduleExpression_Cron(&CronOptionsWithTimezone{
		Minute: jsii.String("0"),
		Hour: jsii.String("23"),
		Day: jsii.String("20"),
		Month: jsii.String("11"),
		TimeZone: awscdk.TimeZone_AMERICA_NEW_YORK(),
	}),
	Target: Target,
	Description: jsii.String("This is a test cron-based schedule that will run at 11:00 PM, on day 20 of the month, only in November in New York timezone"),
})

A one-time schedule is a schedule that invokes a target only once. You configure a one-time schedule by specifying the time of day, date, and time zone in which EventBridge Scheduler evaluates the schedule.

ts
declare const target: targets.LambdaInvoke;

const oneTimeSchedule = new Schedule(this, 'Schedule', {
    schedule: ScheduleExpression.at(
        new Date(2022, 10, 20, 19, 20, 23),
        TimeZone.AMERICA_NEW_YORK,
    ),
    target,
    description: 'This is a one-time schedule in New York timezone',
});
python
# target: targets.LambdaInvoke


one_time_schedule = Schedule(self, "Schedule",
    schedule=ScheduleExpression.at(
        Date(2022, 10, 20, 19, 20, 23), TimeZone.AMERICA_NEW_YORK),
    target=target,
    description="This is a one-time schedule in New York timezone"
)
java
LambdaInvoke target;


Schedule oneTimeSchedule = Schedule.Builder.create(this, "Schedule")
        .schedule(ScheduleExpression.at(
        new Date(2022, 10, 20, 19, 20, 23), TimeZone.AMERICA_NEW_YORK))
        .target(target)
        .description("This is a one-time schedule in New York timezone")
        .build();
csharp
LambdaInvoke target;


var oneTimeSchedule = new Schedule(this, "Schedule", new ScheduleProps {
    Schedule = ScheduleExpression.At(
    new Date(2022, 10, 20, 19, 20, 23), TimeZone.AMERICA_NEW_YORK),
    Target = target,
    Description = "This is a one-time schedule in New York timezone"
});
go
var target LambdaInvoke


oneTimeSchedule := awscdk.NewSchedule(this, jsii.String("Schedule"), &ScheduleProps{
	Schedule: awscdk.ScheduleExpression_At(
	NewDate(jsii.Number(2022), jsii.Number(10), jsii.Number(20), jsii.Number(19), jsii.Number(20), jsii.Number(23)), awscdk.TimeZone_AMERICA_NEW_YORK()),
	Target: Target,
	Description: jsii.String("This is a one-time schedule in New York timezone"),
})

Grouping Schedules ​

Your AWS account comes with a default scheduler group. You can access the default group in CDK with:

ts
const defaultScheduleGroup = ScheduleGroup.fromDefaultScheduleGroup(this, "DefaultGroup");
python
default_schedule_group = ScheduleGroup.from_default_schedule_group(self, "DefaultGroup")
java
IScheduleGroup defaultScheduleGroup = ScheduleGroup.fromDefaultScheduleGroup(this, "DefaultGroup");
csharp
var defaultScheduleGroup = ScheduleGroup.FromDefaultScheduleGroup(this, "DefaultGroup");
go
defaultScheduleGroup := awscdk.ScheduleGroup_FromDefaultScheduleGroup(this, jsii.String("DefaultGroup"))

You can add a schedule to a custom scheduling group managed by you. If a custom group is not specified, the schedule is added to the default group.

ts
declare const target: targets.LambdaInvoke;

const scheduleGroup = new ScheduleGroup(this, "ScheduleGroup", {
    scheduleGroupName: "MyScheduleGroup",
});

new Schedule(this, 'Schedule', {
    schedule: ScheduleExpression.rate(Duration.minutes(10)),
    target,
    scheduleGroup,
});
python
# target: targets.LambdaInvoke


schedule_group = ScheduleGroup(self, "ScheduleGroup",
    schedule_group_name="MyScheduleGroup"
)

Schedule(self, "Schedule",
    schedule=ScheduleExpression.rate(Duration.minutes(10)),
    target=target,
    schedule_group=schedule_group
)
java
LambdaInvoke target;


ScheduleGroup scheduleGroup = ScheduleGroup.Builder.create(this, "ScheduleGroup")
        .scheduleGroupName("MyScheduleGroup")
        .build();

Schedule.Builder.create(this, "Schedule")
        .schedule(ScheduleExpression.rate(Duration.minutes(10)))
        .target(target)
        .scheduleGroup(scheduleGroup)
        .build();
csharp
LambdaInvoke target;


var scheduleGroup = new ScheduleGroup(this, "ScheduleGroup", new ScheduleGroupProps {
    ScheduleGroupName = "MyScheduleGroup"
});

new Schedule(this, "Schedule", new ScheduleProps {
    Schedule = ScheduleExpression.Rate(Duration.Minutes(10)),
    Target = target,
    ScheduleGroup = scheduleGroup
});
go
var target LambdaInvoke


scheduleGroup := awscdk.NewScheduleGroup(this, jsii.String("ScheduleGroup"), &ScheduleGroupProps{
	ScheduleGroupName: jsii.String("MyScheduleGroup"),
})

awscdk.NewSchedule(this, jsii.String("Schedule"), &ScheduleProps{
	Schedule: awscdk.ScheduleExpression_Rate(awscdk.Duration_Minutes(jsii.Number(10))),
	Target: Target,
	ScheduleGroup: ScheduleGroup,
})

Disabling Schedules ​

By default, a schedule will be enabled. You can disable a schedule by setting the enabled property to false:

ts
declare const target: targets.LambdaInvoke;

new Schedule(this, 'Schedule', {
    schedule: ScheduleExpression.rate(Duration.minutes(10)),
    target: target,
    enabled: false,
});
python
# target: targets.LambdaInvoke


Schedule(self, "Schedule",
    schedule=ScheduleExpression.rate(Duration.minutes(10)),
    target=target,
    enabled=False
)
java
LambdaInvoke target;


Schedule.Builder.create(this, "Schedule")
        .schedule(ScheduleExpression.rate(Duration.minutes(10)))
        .target(target)
        .enabled(false)
        .build();
csharp
LambdaInvoke target;


new Schedule(this, "Schedule", new ScheduleProps {
    Schedule = ScheduleExpression.Rate(Duration.Minutes(10)),
    Target = target,
    Enabled = false
});
go
var target LambdaInvoke


awscdk.NewSchedule(this, jsii.String("Schedule"), &ScheduleProps{
	Schedule: awscdk.ScheduleExpression_Rate(awscdk.Duration_Minutes(jsii.Number(10))),
	Target: target,
	Enabled: jsii.Boolean(false),
})

Configuring a start and end time of the Schedule ​

If you choose a recurring schedule, you can set the start and end time of the Schedule by specifying the start and end.

ts
declare const target: targets.LambdaInvoke;

new Schedule(this, 'Schedule', {
    schedule: ScheduleExpression.rate(cdk.Duration.hours(12)),
    target: target,
    start: new Date('2023-01-01T00:00:00.000Z'),
    end: new Date('2023-02-01T00:00:00.000Z'),
});
python
# target: targets.LambdaInvoke


Schedule(self, "Schedule",
    schedule=ScheduleExpression.rate(cdk.Duration.hours(12)),
    target=target,
    start=Date("2023-01-01T00:00:00.000Z"),
    end=Date("2023-02-01T00:00:00.000Z")
)
java
LambdaInvoke target;


Schedule.Builder.create(this, "Schedule")
        .schedule(ScheduleExpression.rate(Duration.hours(12)))
        .target(target)
        .start(new Date("2023-01-01T00:00:00.000Z"))
        .end(new Date("2023-02-01T00:00:00.000Z"))
        .build();
csharp
LambdaInvoke target;


new Schedule(this, "Schedule", new ScheduleProps {
    Schedule = ScheduleExpression.Rate(Duration.Hours(12)),
    Target = target,
    Start = new Date("2023-01-01T00:00:00.000Z"),
    End = new Date("2023-02-01T00:00:00.000Z")
});
go
var target LambdaInvoke


awscdk.NewSchedule(this, jsii.String("Schedule"), &ScheduleProps{
	Schedule: awscdk.ScheduleExpression_Rate(cdk.Duration_Hours(jsii.Number(12))),
	Target: target,
	Start: NewDate(jsii.String("2023-01-01T00:00:00.000Z")),
	End: NewDate(jsii.String("2023-02-01T00:00:00.000Z")),
})

Scheduler Targets ​

The aws-cdk-lib/aws-scheduler-targets module includes classes that implement the IScheduleTarget interface for various AWS services. EventBridge Scheduler supports two types of targets:

  1. Templated targets which invoke common API operations across a core groups of services, and
  2. Universal targets that you can customize to call more than 6,000 operations across over 270 services.

A list of supported targets can be found at aws-cdk-lib/aws-scheduler-targets.

Input ​

Targets can be invoked with a custom input. The ScheduleTargetInput class supports free-form text input and JSON-formatted object input:

ts
const input = ScheduleTargetInput.fromObject({
    'QueueName': 'MyQueue'
});
python
input = ScheduleTargetInput.from_object({
    "QueueName": "MyQueue"
})
java
ScheduleTargetInput input = ScheduleTargetInput.fromObject(Map.of(
        "QueueName", "MyQueue"));
csharp
var input = ScheduleTargetInput.FromObject(new Dictionary<string, string> {
    { "QueueName", "MyQueue" }
});
go
input := awscdk.ScheduleTargetInput_FromObject(map[string]*string{
	"QueueName": jsii.String("MyQueue"),
})

You can include context attributes in your target payload. EventBridge Scheduler will replace each keyword with its respective value and deliver it to the target. See full list of supported context attributes:

  1. ContextAttribute.scheduleArn() – The ARN of the schedule.
  2. ContextAttribute.scheduledTime() – The time you specified for the schedule to invoke its target, e.g., 2022-03-22T18:59:43Z.
  3. ContextAttribute.executionId() – The unique ID that EventBridge Scheduler assigns for each attempted invocation of a target, e.g., d32c5kddcf5bb8c3.
  4. ContextAttribute.attemptNumber() – A counter that identifies the attempt number for the current invocation, e.g., 1.
ts
const text = `Attempt number: ${ContextAttribute.attemptNumber}`;
const input = ScheduleTargetInput.fromText(text);
python
text = f"Attempt number: {ContextAttribute.attemptNumber}"
input = ScheduleTargetInput.from_text(text)
java
String text = String.format("Attempt number: %s", ContextAttribute.getAttemptNumber());
ScheduleTargetInput input = ScheduleTargetInput.fromText(text);
csharp
var text = $"Attempt number: {ContextAttribute.attemptNumber}";
var input = ScheduleTargetInput.FromText(text);
go
text := fmt.Sprintf("Attempt number: %v", awscdk.ContextAttribute_AttemptNumber())
input := awscdk.ScheduleTargetInput_FromText(text)

Specifying an execution role ​

An execution role is an IAM role that EventBridge Scheduler assumes in order to interact with other AWS services on your behalf.

The classes for templated schedule targets automatically create an IAM role with all the minimum necessary permissions to interact with the templated target. If you wish you may specify your own IAM role, then the templated targets will grant minimal required permissions. For example, the LambdaInvoke target will grant the IAM execution role lambda:InvokeFunction permission to invoke the Lambda function.

ts
declare const fn: lambda.Function;

const role = new iam.Role(this, 'Role', {
    assumedBy: new iam.ServicePrincipal('scheduler.amazonaws.com'),
});

const target = new targets.LambdaInvoke(fn, {
    input: ScheduleTargetInput.fromObject({
        "payload": "useful"
    }),
    role,
});
python
# fn: lambda.Function


role = iam.Role(self, "Role",
    assumed_by=iam.ServicePrincipal("scheduler.amazonaws.com")
)

target = targets.LambdaInvoke(fn,
    input=ScheduleTargetInput.from_object({
        "payload": "useful"
    }),
    role=role
)
java
Function fn;


Role role = Role.Builder.create(this, "Role")
        .assumedBy(new ServicePrincipal("scheduler.amazonaws.com"))
        .build();

LambdaInvoke target = LambdaInvoke.Builder.create(fn)
        .input(ScheduleTargetInput.fromObject(Map.of(
                "payload", "useful")))
        .role(role)
        .build();
csharp
Function fn;


var role = new Role(this, "Role", new RoleProps {
    AssumedBy = new ServicePrincipal("scheduler.amazonaws.com")
});

var target = new LambdaInvoke(fn, new ScheduleTargetBaseProps {
    Input = ScheduleTargetInput.FromObject(new Dictionary<string, string> {
        { "payload", "useful" }
    }),
    Role = role
});
go
var fn Function


role := iam.NewRole(this, jsii.String("Role"), &RoleProps{
	AssumedBy: iam.NewServicePrincipal(jsii.String("scheduler.amazonaws.com")),
})

target := targets.NewLambdaInvoke(fn, &ScheduleTargetBaseProps{
	Input: awscdk.ScheduleTargetInput_FromObject(map[string]*string{
		"payload": jsii.String("useful"),
	}),
	Role: Role,
})

Specifying an encryption key ​

EventBridge Scheduler integrates with AWS Key Management Service (AWS KMS) to encrypt and decrypt your data using an AWS KMS key. EventBridge Scheduler supports two types of KMS keys: AWS owned keys, and customer managed keys.

By default, all events in Scheduler are encrypted with a key that AWS owns and manages. If you wish you can also provide a customer managed key to encrypt and decrypt the payload that your schedule delivers to its target using the key property. Target classes will automatically add AWS kms:Decrypt permission to your schedule's execution role permissions policy.

ts
declare const key: kms.Key;
declare const fn: lambda.Function;

const target = new targets.LambdaInvoke(fn, {
    input: ScheduleTargetInput.fromObject({
        payload: 'useful',
    }),
});

const schedule = new Schedule(this, 'Schedule', {
    schedule: ScheduleExpression.rate(Duration.minutes(10)),
    target,
    key,
});
python
# key: kms.Key
# fn: lambda.Function


target = targets.LambdaInvoke(fn,
    input=ScheduleTargetInput.from_object({
        "payload": "useful"
    })
)

schedule = Schedule(self, "Schedule",
    schedule=ScheduleExpression.rate(Duration.minutes(10)),
    target=target,
    key=key
)
java
Key key;
Function fn;


LambdaInvoke target = LambdaInvoke.Builder.create(fn)
        .input(ScheduleTargetInput.fromObject(Map.of(
                "payload", "useful")))
        .build();

Schedule schedule = Schedule.Builder.create(this, "Schedule")
        .schedule(ScheduleExpression.rate(Duration.minutes(10)))
        .target(target)
        .key(key)
        .build();
csharp
Key key;
Function fn;


var target = new LambdaInvoke(fn, new ScheduleTargetBaseProps {
    Input = ScheduleTargetInput.FromObject(new Dictionary<string, string> {
        { "payload", "useful" }
    })
});

var schedule = new Schedule(this, "Schedule", new ScheduleProps {
    Schedule = ScheduleExpression.Rate(Duration.Minutes(10)),
    Target = target,
    Key = key
});
go
var key Key
var fn Function


target := targets.NewLambdaInvoke(fn, &ScheduleTargetBaseProps{
	Input: awscdk.ScheduleTargetInput_FromObject(map[string]*string{
		"payload": jsii.String("useful"),
	}),
})

schedule := awscdk.NewSchedule(this, jsii.String("Schedule"), &ScheduleProps{
	Schedule: awscdk.ScheduleExpression_Rate(awscdk.Duration_Minutes(jsii.Number(10))),
	Target: Target,
	Key: Key,
})

See Data protection in Amazon EventBridge Scheduler for more details.

Configuring flexible time windows ​

You can configure flexible time windows by specifying the timeWindow property. Flexible time windows are disabled by default.

ts
declare const target: targets.LambdaInvoke;

const schedule = new Schedule(this, 'Schedule', {
    schedule: ScheduleExpression.rate(Duration.hours(12)),
    target,
    timeWindow: TimeWindow.flexible(Duration.hours(10)),
});
python
# target: targets.LambdaInvoke


schedule = Schedule(self, "Schedule",
    schedule=ScheduleExpression.rate(Duration.hours(12)),
    target=target,
    time_window=TimeWindow.flexible(Duration.hours(10))
)
java
LambdaInvoke target;


Schedule schedule = Schedule.Builder.create(this, "Schedule")
        .schedule(ScheduleExpression.rate(Duration.hours(12)))
        .target(target)
        .timeWindow(TimeWindow.flexible(Duration.hours(10)))
        .build();
csharp
LambdaInvoke target;


var schedule = new Schedule(this, "Schedule", new ScheduleProps {
    Schedule = ScheduleExpression.Rate(Duration.Hours(12)),
    Target = target,
    TimeWindow = TimeWindow.Flexible(Duration.Hours(10))
});
go
var target LambdaInvoke


schedule := awscdk.NewSchedule(this, jsii.String("Schedule"), &ScheduleProps{
	Schedule: awscdk.ScheduleExpression_Rate(awscdk.Duration_Hours(jsii.Number(12))),
	Target: Target,
	TimeWindow: awscdk.TimeWindow_Flexible(awscdk.Duration_*Hours(jsii.Number(10))),
})

See Configuring flexible time windows for more details.

Error-handling ​

You can configure how your schedule handles failures, when EventBridge Scheduler is unable to deliver an event successfully to a target, by using two primary mechanisms: a retry policy, and a dead-letter queue (DLQ).

A retry policy determines the number of times EventBridge Scheduler must retry a failed event, and how long to keep an unprocessed event.

A DLQ is a standard Amazon SQS queue EventBridge Scheduler uses to deliver failed events to, after the retry policy has been exhausted. You can use a DLQ to troubleshoot issues with your schedule or its downstream target. If you've configured a retry policy for your schedule, EventBridge Scheduler delivers the dead-letter event after exhausting the maximum number of retries you set in the retry policy.

ts
declare const fn: lambda.Function;

const dlq = new sqs.Queue(this, "DLQ", {
    queueName: 'MyDLQ',
});

const target = new targets.LambdaInvoke(fn, {
    deadLetterQueue: dlq,
    maxEventAge: Duration.minutes(1),
    retryAttempts: 3
});
python
# fn: lambda.Function


dlq = sqs.Queue(self, "DLQ",
    queue_name="MyDLQ"
)

target = targets.LambdaInvoke(fn,
    dead_letter_queue=dlq,
    max_event_age=Duration.minutes(1),
    retry_attempts=3
)
java
Function fn;


Queue dlq = Queue.Builder.create(this, "DLQ")
        .queueName("MyDLQ")
        .build();

LambdaInvoke target = LambdaInvoke.Builder.create(fn)
        .deadLetterQueue(dlq)
        .maxEventAge(Duration.minutes(1))
        .retryAttempts(3)
        .build();
csharp
Function fn;


var dlq = new Queue(this, "DLQ", new QueueProps {
    QueueName = "MyDLQ"
});

var target = new LambdaInvoke(fn, new ScheduleTargetBaseProps {
    DeadLetterQueue = dlq,
    MaxEventAge = Duration.Minutes(1),
    RetryAttempts = 3
});
go
var fn Function


dlq := sqs.NewQueue(this, jsii.String("DLQ"), &QueueProps{
	QueueName: jsii.String("MyDLQ"),
})

target := targets.NewLambdaInvoke(fn, &ScheduleTargetBaseProps{
	DeadLetterQueue: dlq,
	MaxEventAge: awscdk.Duration_Minutes(jsii.Number(1)),
	RetryAttempts: jsii.Number(3),
})

Monitoring ​

You can monitor Amazon EventBridge Scheduler using CloudWatch, which collects raw data and processes it into readable, near real-time metrics. EventBridge Scheduler emits a set of metrics for all schedules, and an additional set of metrics for schedules that have an associated dead-letter queue (DLQ). If you configure a DLQ for your schedule, EventBridge Scheduler publishes additional metrics when your schedule exhausts its retry policy.

Metrics for all schedules ​

The Schedule class provides static methods for accessing all schedules metrics with default configuration, such as metricAllErrors for viewing errors when executing targets.

ts
new cloudwatch.Alarm(this, 'SchedulesErrorAlarm', {
   metric: Schedule.metricAllErrors(),
   threshold: 0,
   evaluationPeriods: 1,
});

Metrics for a Schedule Group ​

To view metrics for a specific group you can use methods on class ScheduleGroup:

ts
const scheduleGroup = new ScheduleGroup(this, "ScheduleGroup", {
    scheduleGroupName: "MyScheduleGroup",
});

new cloudwatch.Alarm(this, 'MyGroupErrorAlarm', {
    metric: scheduleGroup.metricTargetErrors(),
    evaluationPeriods: 1,
    threshold: 0
});

// Or use default group
const defaultScheduleGroup = ScheduleGroup.fromDefaultScheduleGroup(this, "DefaultScheduleGroup");
new cloudwatch.Alarm(this, 'DefaultScheduleGroupErrorAlarm', {
    metric: defaultScheduleGroup.metricTargetErrors(),
    evaluationPeriods: 1,
    threshold: 0
});
python
schedule_group = ScheduleGroup(self, "ScheduleGroup",
    schedule_group_name="MyScheduleGroup"
)

cloudwatch.Alarm(self, "MyGroupErrorAlarm",
    metric=schedule_group.metric_target_errors(),
    evaluation_periods=1,
    threshold=0
)

# Or use default group
default_schedule_group = ScheduleGroup.from_default_schedule_group(self, "DefaultScheduleGroup")
cloudwatch.Alarm(self, "DefaultScheduleGroupErrorAlarm",
    metric=default_schedule_group.metric_target_errors(),
    evaluation_periods=1,
    threshold=0
)
java
ScheduleGroup scheduleGroup = ScheduleGroup.Builder.create(this, "ScheduleGroup")
        .scheduleGroupName("MyScheduleGroup")
        .build();

Alarm.Builder.create(this, "MyGroupErrorAlarm")
        .metric(scheduleGroup.metricTargetErrors())
        .evaluationPeriods(1)
        .threshold(0)
        .build();

// Or use default group
IScheduleGroup defaultScheduleGroup = ScheduleGroup.fromDefaultScheduleGroup(this, "DefaultScheduleGroup");
Alarm.Builder.create(this, "DefaultScheduleGroupErrorAlarm")
        .metric(defaultScheduleGroup.metricTargetErrors())
        .evaluationPeriods(1)
        .threshold(0)
        .build();
csharp
var scheduleGroup = new ScheduleGroup(this, "ScheduleGroup", new ScheduleGroupProps {
    ScheduleGroupName = "MyScheduleGroup"
});

new Alarm(this, "MyGroupErrorAlarm", new AlarmProps {
    Metric = scheduleGroup.MetricTargetErrors(),
    EvaluationPeriods = 1,
    Threshold = 0
});

// Or use default group
var defaultScheduleGroup = ScheduleGroup.FromDefaultScheduleGroup(this, "DefaultScheduleGroup");
new Alarm(this, "DefaultScheduleGroupErrorAlarm", new AlarmProps {
    Metric = defaultScheduleGroup.MetricTargetErrors(),
    EvaluationPeriods = 1,
    Threshold = 0
});
go
scheduleGroup := awscdk.NewScheduleGroup(this, jsii.String("ScheduleGroup"), &ScheduleGroupProps{
	ScheduleGroupName: jsii.String("MyScheduleGroup"),
})

cloudwatch.NewAlarm(this, jsii.String("MyGroupErrorAlarm"), &AlarmProps{
	Metric: scheduleGroup.metricTargetErrors(),
	EvaluationPeriods: jsii.Number(1),
	Threshold: jsii.Number(0),
})

// Or use default group
defaultScheduleGroup := awscdk.ScheduleGroup_FromDefaultScheduleGroup(this, jsii.String("DefaultScheduleGroup"))
cloudwatch.NewAlarm(this, jsii.String("DefaultScheduleGroupErrorAlarm"), &AlarmProps{
	Metric: defaultScheduleGroup.MetricTargetErrors(),
	EvaluationPeriods: jsii.Number(1),
	Threshold: jsii.Number(0),
})

See full list of metrics and their description at Monitoring Using CloudWatch Metrics in the AWS EventBridge Scheduler User Guide.

Types ​

NameKindSummary
ScheduleConstruct (L2)An EventBridge Schedule.
ScheduleGroupConstruct (L2)A Schedule Group.
CfnScheduleConstruct (L1)A schedule is the main resource you create, configure, and manage using Amazon EventBridge Scheduler.
CfnScheduleGroupConstruct (L1)A schedule group is an Amazon EventBridge Scheduler resource you use to organize your schedules.
CfnSchedule.AwsVpcConfigurationPropertyStructThis structure specifies the VPC subnets and security groups for the task, and whether a public IP address is to be used.
CfnSchedule.CapacityProviderStrategyItemPropertyStructThe details of a capacity provider strategy.
CfnSchedule.DeadLetterConfigPropertyStructAn object that contains information about an Amazon SQS queue that EventBridge Scheduler uses as a dead-letter queue for your schedule.
CfnSchedule.EcsParametersPropertyStructThe templated target type for the Amazon ECS RunTask API operation.
CfnSchedule.EventBridgeParametersPropertyStructThe templated target type for the EventBridge PutEvents API operation.
CfnSchedule.FlexibleTimeWindowPropertyStructAllows you to configure a time window during which EventBridge Scheduler invokes the schedule.
CfnSchedule.KinesisParametersPropertyStructThe templated target type for the Amazon Kinesis PutRecord API operation.
CfnSchedule.NetworkConfigurationPropertyStructSpecifies the network configuration for an ECS task.
CfnSchedule.PlacementConstraintPropertyStructAn object representing a constraint on task placement.
CfnSchedule.PlacementStrategyPropertyStructThe task placement strategy for a task or service.
CfnSchedule.RetryPolicyPropertyStructA RetryPolicy object that includes information about the retry policy settings, including the maximum age of an event, and the maximum number of times EventBridge Scheduler will try to deliver the event to a target.
CfnSchedule.SageMakerPipelineParameterPropertyStructThe name and value pair of a parameter to use to start execution of a SageMaker Model Building Pipeline.
CfnSchedule.SageMakerPipelineParametersPropertyStructThe templated target type for the Amazon SageMaker StartPipelineExecution API operation.
CfnSchedule.SqsParametersPropertyStructThe templated target type for the Amazon SQS SendMessage API operation. Contains the message group ID to use when the target is a FIFO queue. If you specify an Amazon SQS FIFO queue as a target, the queue must have content-based deduplication enabled. For more information, see Using the Amazon SQS message deduplication ID in the Amazon SQS Developer Guide .
CfnSchedule.TargetPropertyStructThe schedule's target.
CfnScheduleGroupPropsStructProperties for defining a CfnScheduleGroup.
CfnSchedulePropsStructProperties for defining a CfnSchedule.
ContextAttributeClassA set of convenient static methods representing the Scheduler Context Attributes.
CronOptionsWithTimezoneStructOptions to configure a cron expression.
IScheduleInterfaceInterface representing a created or an imported Schedule.
IScheduleGroupInterfaceInterface representing a created or an imported ScheduleGroup.
IScheduleTargetInterfaceInterface representing a Event Bridge Schedule Target.
ScheduleExpressionClassScheduleExpression for EventBridge Schedule.
ScheduleGroupGrantsFacadeCollection of grant methods for a IScheduleGroupRef.
ScheduleGroupPropsStructProperties for a Schedule Group.
SchedulePropsStructConstruction properties for Schedule.
ScheduleTargetConfigStructConfig of a Schedule Target used during initialization of Schedule.
ScheduleTargetInputClassThe text or well-formed JSON input passed to the target of the schedule.
TimeWindowClassA time window during which EventBridge Scheduler invokes the schedule.