0

I have a cron that is suppose to run at 9am Eastern. We had this problem last time change and thought we found a solution by using the TZ env var, but it does not seem to have fixed it. It seems that now it is running at 10am Eastern.

serverless.yml

provider:
  environment:
    TZ: America/New_York

We figured from reading the docs this would fix it, but it hasn't. Any help would be greatly appreciated.

Mark B
  • 183,023
  • 24
  • 297
  • 295
Taylor Austin
  • 5,407
  • 15
  • 58
  • 103
  • The Serverless framework is creating AWS Event Bridge cron triggers. AWS Event Bridge uses UTC for cron schedules. UTC does not have daylight savings time. – Mark B Mar 15 '22 at 15:24
  • So the `TZ` variable is pointless? @MarkB . Is there a way to work around time changes in serverless? – Taylor Austin Mar 15 '22 at 15:30
  • The `TZ` parameter isn't documented [here](https://www.serverless.com/framework/docs/providers/aws/guide/serverless.yml/). So it looks like you just made it up. So yes that would be pointless. – Mark B Mar 15 '22 at 15:34
  • The serverless framework is just a system for creating AWS resources. Once the resources are created the serverless framework is done, and it's up to AWS to do things like trigger your cron jobs. There is currently no way to make AWS take timezones into account for cron jobs, as documented in the other post I linked. – Mark B Mar 15 '22 at 15:36
  • @MarkB It's an aws reserved env var, I did not make it up haha. – Taylor Austin Mar 15 '22 at 15:36
  • What you are referring to is a Lambda function environment variable. That would be set under `functions: functionname: environment:` not `provider: environment`. So yes you just made up the provider setting. Also, the fact it is reserved means you can't override the value. Finally, that environment variable is for Lambda functions, not Event Bridge. The cron schedule happens in Event Bridge. – Mark B Mar 15 '22 at 15:39
  • Thank you for your patience and help @MarkB. I'm pretty new to aws/serverless and read things wrong from other post. – Taylor Austin Mar 15 '22 at 15:59

0 Answers0