Get (exact) scheduled cron time in lambda

Hi-

I’ve got a use case where I need to run a scheduled lambda via cron periodically, like every 15 minutes, and I need to query a DynamoDB table to for entries where the key is the exact epoch when the cron was scheduled to run. For example, if the lambda is scheduled to run at
1/1/22 09:15:00, I need that epoch, and not the current time when the lambda is actually started (typically a few seconds later). Is there any way to get that “scheduled time” in the lambda function?

Alternatively it seems like I can probably take the current time and round it down to the 15 minute interval. Annoying, but not the end of the world I guess as long as the lambda never starts BEFORE the scheduled time. I assume that it always runs at or slightly after the scheduled time.

I really thought I saw this information in the past, but I can’t seem to find it in any of my current lambda cron logs…

Any suggestions would be appreciated.

Thanks!

The event data passed to the lambda from the CloudWatch schedule includes an event time. Here is a sample of what CloudWatch passes:

{
  "id": "cdc73f9d-aea9-11e3-9d5a-835b769c0d9c",
  "detail-type": "Scheduled Event",
  "source": "aws.events",
  "account": "123456789012",
  "time": "1970-01-01T00:00:00Z",
  "region": "us-east-1",
  "resources": [
    "arn:aws:events:us-east-1:123456789012:rule/ExampleRule"
  ],
  "detail": {}
}

I haven’t used the time field myself but I believe it is when the trigger fired.

Hi, thanks for sharing.