I have multiple cloud watch events triggering a lambda function . Is it possible to get name of event in lambda function so that I can know which is triggering lambda function and need to do some changes accordingly.
Asked
Active
Viewed 636 times
0
-
1You can customize the payload of the event sent to your lambda function on each event trigger (under Configure Input section), you can introduce a new property and set different values for different events. This will allow you to check for that property in your lambda code. – A.Amayreh Mar 03 '22 at 07:06
1 Answers
0
Formalising response from the comments. @A.Amayreh
Simply add it in the event payload while creating it.
Rule Payload:
{
...,
"event_name":"my_event_1"
}
This way your lambda knows the source event while executing.

Nick
- 179
- 1
- 10
-
getting "Invalid target selected". As its AWS event for ECR scan so cant add anything in event pattern . – Manpreet Narang Mar 09 '22 at 03:44
-
Just for clarity, in the "Amazon EventBridge" (AKA CloudWatch Events), it's under the Target tab that this can be configured. For example, it can be possible to set the Event (in its most simple form) to a constant JSON object. But it's possible to do much more ... – Christophe Vidal Jan 20 '23 at 10:51