5

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)

kicaj
  • 2,881
  • 5
  • 42
  • 68

2 Answers2

3

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.

Ninad Gaikwad
  • 4,272
  • 2
  • 13
  • 23
0

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,
  },
});
Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Jing Ma
  • 183
  • 2
  • 12