It is possible to set schedule cron time in local time in AWS CloudWatch?
Use CET/CEST instead of GMT?
E.g. I would like set cron time on 13:00 local time, without calculation timezone diff (1 hour on winter time, 2 hours on summer time)
It is possible to set schedule cron time in local time in AWS CloudWatch?
Use CET/CEST instead of GMT?
E.g. I would like set cron time on 13:00 local time, without calculation timezone diff (1 hour on winter time, 2 hours on summer time)
Cloudwatch events use UTC time only. To achieve what you want you can use another lambda to keep updating the cloudwatch trigger. Have a look at this post for a good example.
This is possible using the EventBridge Scheduler
. In below example I'm scheduling a lambda at 6 am and 8 am, from Monday to Friday.
// Lambda
const func = new NodejsFunction(this, 'func-id', {
runtime: Runtime.NODEJS_18_X
});
// Role
const role = new Role(this, 'role-id', {
managedPolicies: [{ managedPolicyArn: 'arn:aws:iam::aws:policy/service-role/AWSLambdaRole' }],
assumedBy: new ServicePrincipal('scheduler.amazonaws.com')
});
// EventBridge Schedule
new CfnSchedule(this, 'schedule-id', {
flexibleTimeWindow: {
mode: 'OFF',
},
scheduleExpression: 'cron(0 6,8 ? * MON-FRI *)',
scheduleExpressionTimezone: 'Europe/Amsterdam',
target: {
arn: func.functionArn,
roleArn: role.roleArn,
},
});