ScheduleExpression Class
ScheduleExpression for EventBridge Schedule.
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.
| Source | aws-scheduler/lib/schedule-expression.ts |
|---|---|
| Type last changed |
Example
ts
import * as firehose from 'aws-cdk-lib/aws-kinesisfirehose';
declare const deliveryStream: firehose.IDeliveryStream;
const payload = {
Data: "record",
};
new Schedule(this, 'Schedule', {
schedule: ScheduleExpression.rate(Duration.minutes(60)),
target: new targets.FirehosePutRecord(deliveryStream, {
input: ScheduleTargetInput.fromObject(payload),
}),
});
python
import aws_cdk.aws_kinesisfirehose as firehose
# delivery_stream: firehose.IDeliveryStream
payload = {
"Data": "record"
}
Schedule(self, "Schedule",
schedule=ScheduleExpression.rate(Duration.minutes(60)),
target=targets.FirehosePutRecord(delivery_stream,
input=ScheduleTargetInput.from_object(payload)
)
)
java
import software.amazon.awscdk.services.kinesisfirehose.*;
IDeliveryStream deliveryStream;
Map<String, String> payload = Map.of(
"Data", "record");
Schedule.Builder.create(this, "Schedule")
.schedule(ScheduleExpression.rate(Duration.minutes(60)))
.target(FirehosePutRecord.Builder.create(deliveryStream)
.input(ScheduleTargetInput.fromObject(payload))
.build())
.build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.KinesisFirehose;
IDeliveryStream deliveryStream;
IDictionary<string, string> payload = new Dictionary<string, string> {
{ "Data", "record" }
};
new Schedule(this, "Schedule", new ScheduleProps {
Schedule = ScheduleExpression.Rate(Duration.Minutes(60)),
Target = new FirehosePutRecord(deliveryStream, new ScheduleTargetBaseProps {
Input = ScheduleTargetInput.FromObject(payload)
})
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import firehose "github.com/aws/aws-cdk-go/awscdk"
var deliveryStream IDeliveryStream
payload := map[string]*string{
"Data": jsii.String("record"),
}
awscdk.NewSchedule(this, jsii.String("Schedule"), &ScheduleProps{
Schedule: awscdk.ScheduleExpression_Rate(awscdk.Duration_Minutes(jsii.Number(60))),
Target: targets.NewFirehosePutRecord(deliveryStream, &ScheduleTargetBaseProps{
Input: awscdk.ScheduleTargetInput_FromObject(payload),
}),
})
Initializer
ts
new ScheduleExpression()
python
ScheduleExpression()
java
new ScheduleExpression()
csharp
new ScheduleExpression()
go
NewScheduleExpression()
Properties
expressionStringstringexpression_stringstrexpressionStringStringExpressionStringstringExpressionString*string #Retrieve the expression for this schedule.
Methods
at(date: date, timeZone?: TimeZone): ScheduleExpression // chainable@staticmethod def at(date: datetime, time_zone: typing.Optional[TimeZone] = None) -> ScheduleExpressionpublic static ScheduleExpression at(Instant date, TimeZone timeZone)public static ScheduleExpression At(DateTime date, TimeZone? timeZone = null)func At(Date *time.Time, TimeZone TimeZone) ScheduleExpression static #Construct a one-time schedule from a date.
2 parameters
Parameters
datedatedatedateDate— The date and time to use.timeZonetime_zonetimeZonetimeZoneTimeZone— The time zone to use for interpreting the date.
cron(options: CronOptionsWithTimezone): ScheduleExpression // chainable@staticmethod def cron(options: CronOptionsWithTimezone) -> ScheduleExpressionpublic static ScheduleExpression cron(CronOptionsWithTimezone options)public static ScheduleExpression Cron(CronOptionsWithTimezone options)func Cron(Options CronOptionsWithTimezone) ScheduleExpression static #Create a recurring schedule from a set of cron fields and time zone.
expression(expression: string, timeZone?: TimeZone): ScheduleExpression // chainable@staticmethod def expression(expression: str, time_zone: typing.Optional[TimeZone] = None) -> ScheduleExpressionpublic static ScheduleExpression expression(String expression, TimeZone timeZone)public static ScheduleExpression Expression(string expression, TimeZone? timeZone = null)func Expression(Expression *string, TimeZone TimeZone) ScheduleExpression static #Construct a schedule from a literal schedule expression.
2 parameters
Parameters
expressionexpressionexpressionexpressionExpression— The expression to use.timeZonetime_zonetimeZonetimeZoneTimeZone— The time zone to use for interpreting the expression.
rate(duration: Duration): ScheduleExpression // chainable@staticmethod def rate(duration: Duration) -> ScheduleExpressionpublic static ScheduleExpression rate(Duration duration)public static ScheduleExpression Rate(Duration duration)func Rate(Duration Duration) ScheduleExpression static #Construct a recurring 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.