Reputation: 303
My AWS lambda function is getting invoked my multiple places like api-gateway, aws-SNS and cloud-watch event. Is there any way to figure out who invoked the lambda function? My lambda function's logic depends on the invoker.
Another way to achieve this is having three different lambda functions but I don't want to go that way if I can find invoker information in a single Lambda function itself.
Upvotes: 2
Views: 2352
Reputation: 238199
I would look at the event
object as all of the three services will have event
of different structure.
For example, for CloudWatch Events I would check if there is a source
field in the event
. For SNS I would check for Records
and API gateway for httpMethod
.
But you can check for any other attribute that is unique to a given service. If you are not sure, just print out to logs example events from your function for the three services and check what would be the most suited attribute to look for.
Upvotes: 5