aws-cdk-lib.aws_events.Schedule

class Schedule

LanguageType name
.NETAmazon.CDK.AWS.Events.Schedule
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsevents#Schedule
Javasoftware.amazon.awscdk.services.events.Schedule
Pythonaws_cdk.aws_events.Schedule
TypeScript (source)aws-cdk-lib » aws_events » Schedule

Schedule for scheduled event rules.

Note that rates cannot be defined in fractions of minutes.

See also: https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html

Example

import * as ecs from "aws-cdk-lib/aws-ecs"
declare const cluster: ecs.ICluster
declare const taskDefinition: ecs.TaskDefinition

const rule = new events.Rule(this, 'Rule', {
  schedule: events.Schedule.rate(cdk.Duration.hours(1)),
});

rule.addTarget(new targets.EcsTask({
  cluster,
  taskDefinition,
  taskCount: 1,
  containerOverrides: [{
    containerName: 'TheContainer',
    command: ['echo', events.EventField.fromPath('$.detail.event')],
  }],
  enableExecuteCommand: true,
}));

Initializer

new Schedule()

Properties

NameTypeDescription
expressionStringstringRetrieve the expression for this schedule.

expressionString

Type: string

Retrieve the expression for this schedule.

Methods

NameDescription
static cron(options)Create a schedule from a set of cron fields.
static expression(expression)Construct a schedule from a literal schedule expression.
static rate(duration)Construct a schedule from an interval and a time unit.

static cron(options)

public static cron(options: CronOptions): Schedule

Parameters

  • options CronOptions

Returns

  • Schedule

Create a schedule from a set of cron fields.


static expression(expression)

public static expression(expression: string): Schedule

Parameters

  • expression string — The expression to use.

Returns

  • Schedule

Construct a schedule from a literal schedule expression.


static rate(duration)

public static rate(duration: Duration): Schedule

Parameters

  • duration Duration

Returns

  • Schedule

Construct a schedule from an interval and a time unit.

Rates may be defined with any unit of time, but when converted into minutes, the duration must be a positive whole number of minutes.