I have a lambda function that was deployed using cdk, it contains several rules that runs on a schedule determined by cron expression. For example, one of them need to run according to cron(0 16 ? * MON-SAT *)
during fall and according to cron(0 15 ? * MON-SAT *)
during spring time. Currently we need to update the cron expression manually twice a year and we are looking for a way to automate it. How can we do it (using cdk)?
new cdk.aws_events.Rule(this, `example${name}EventRule${appEnv}`, {
enabled: event.enabled ?? true,
description: `example-${name}-Schedule-${appEnv}`,
ruleName: `example-${name}-Schedule-${appEnv}`,
targets: [
new cdk.aws_events_targets.LambdaFunction(exampleLambda, {
event: RuleTargetInput.fromObject({
Endpoint,
suiteName,
sendMail,
deliveryCondition,
pagerDuty,
emailList
})
})
],
schedule: aws_events.Schedule.expression(schedule)
});
});
Tried to update the cron expression, but it didn’t work.
Is there another way for doing that?