Reputation: 51
Lambda L1 is subscribed to SNS S1.
L1 returns the status code and a message every time it is invoked
I can check L1 response every time it is invoked independently but when I invoke L1 by publishing a message to S1, how can I verify the message returned from L1?
I need to do this programmatically in java.. Any pointers are appreciated
Upvotes: 3
Views: 2640
Reputation: 1953
In SNS trigger or any other asynchronous trigger, there isn't any 'server' that receives the return value of the Lambda.
For that reason, the Dead Letter Queue is a feature that makes it possible to handle errors in such a case, and it might be what you are looking for.
If you wish to verify every message returned (and not only failures of the Lambda), you may have it configured to send the return message to another queue (SNS/SQS) and use another Lambda to make the verification.
If you just look for monitoring your application (so you don't have any immediate action to take place in a verification failure), you may look for a monitoring solution - whether configuring CloudWatch metrics, Sentry or another.
Upvotes: 2
Reputation: 270224
Amazon SNS publishes messages to subscribers. Once a message is successfully sent to a subscriber (eg to AWS Lambda to trigger a Lambda function), it does not wait for a response.
Therefore, it is not possible to view the response code of a Lambda function triggered by SNS.
You could look in the CloudWatch Log that is generated by the Lambda function, but you might need to insert code to push the response to the log (eg via a Print statement).
Upvotes: 6