CronOptionsWithTimezone Struct
Options to configure a cron expression.
All fields are strings so you can use complex expressions. Absence of a field implies '*' or '?', whichever one is appropriate.
| Source | aws-scheduler/lib/schedule-expression.ts |
|---|---|
| Type last changed |
Example
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
// Install: dotnet add package Amazon.CDK.Lib
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
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
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"),
})
Properties
The day of the month to run this rule at.
Default: Every day of the month
The hour to run this rule at.
Default: Every hour
minuteoptionalstringminuteoptionalstrminuteoptionalStringMinuteoptionalstringMinuteoptional*string #The minute to run this rule at.
Default: Every minute
The month to run this rule at.
Default: Every month
timeZoneoptionalTimeZonetime_zoneoptionalTimeZonetimeZoneoptionalTimeZoneTimeZoneoptionalTimeZoneTimeZoneoptionalTimeZone = TimeZone.ETC_UTC #The timezone to run the schedule in.
weekDayoptionalstringweek_dayoptionalstrweekDayoptionalStringWeekDayoptionalstringWeekDayoptional*string #The day of the week to run this rule at.
Default: Any day of the week
The year to run this rule at.
Default: Every year