How do I access the serverless requestId in cron initiated lambdas?

When the trigger for a lambda is Api Gateway, the event object has event.requestContext.requestId, when triggering the same lambda from a cron job, there is not requestContext and no requestId.

Is there a way to pass the requestId to the lambda?

That’s because requestId is a property of the API Gateway event type and not the Cloudwatch event type.

See Using AWS Lambda with Other Services for examples of event payloads you can expect from the various other services.
For this comparison, look at:

1 Like

I think I get what you mean. Just to make sure, are you talking about the requestId used by Serverless? e.g., the one highlighted here:

Also, if that’s the case, is there any way to map AWS’s requestId to Serverless’s requestId?