如何更改 AWS Cloudwatch Event Cron 表达式中的时区?

How to change the Timezone in AWS Cloudwatch Event Cron expression?

需求:我们有4个客户端,分布在4个不同的区域,需要在每天特定时间触发lambda的cloud watch事件中设置一个Cron表达式。

目前Cloudwatch是基于GMT触发事件,如何更改时区?

您必须自己计算不同区域的 GMT 时间,然后在 EventBridge (CloudWatch) 中进行设置。

例如,如果您想在纽约市 (EDT) 当地时间凌晨 5 点触发事件,则需要将其转换为 GMT 时间。现在是上午 9 点。然后在 EventBridge (CloudWatch) 事件中设置该值。

如果您使用的是Serverless, then you can use the Serverless Local Schedule插件,它可以为您进行时区转换。

events:
  - schedule:
      rate: cron(0 8-20 * * ? *)
      timezone: Australia/Sydney

plugins:
  - serverless-local-schedule