Reputation: 15042
I have a CloudWatch scheduled event invoking a Lambda function.
The event is currently passing a JSON with some parameters. One of which contains the event name, handwritten, which isn't very elegant and can lead to typos.
I cannot choose to pass the Matched event
, as I am also passing some other parameters as JSON.
So I would somehow need to pass the event as a parameter in that JSON object, but I couldn't find any docs about that.
How can I get the invoking event name inside the Lambda function?
Upvotes: 2
Views: 985
Reputation: 7770
You can use input transformer which can be used to add your own stuff plus something from the meta data available. In your case
Input path will be
{"ruleName":"$.resources[0]"}
While the Input template will be
{"yourKey": "yourValue", "ruleName": <ruleName>}
And this is how it will be available in your lambda function
{
yourKey: 'yourValue',
ruleName: 'arn:aws:events:someregion:someaccountId:rule/testevent'
}
Hope this helps.
Upvotes: 1