1 Answer
- Newest
- Most votes
- Most comments
2
Hi,
you are seeing this behavior because the Lambda function L2 is configured as a successful asynchronous destination. That means, it is only invoked when the initial invoke was a async request. So, in your case,
- The invoke from the user is done synchronously, therefore the destination is not triggered
- When SQS is used as a event source, Lambda polls the queue and invokes your Lambda function synchronously (see https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html), therefore the destination is not triggered
- For the code that you shared, make sure to set the
InvocationType
toEvent
, see https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/lambda/model/InvokeRequest.html#setInvocationType-com.amazonaws.services.lambda.model.InvocationType-
Basically, the destination is only invoked for asynchronous requests.
To add some context: The primary use case of Destinations is to know about the async execution results of Lambda functions, primarily to get more visibility into the execution details like request and response contexts, payloads, exception stack traces and so on.
Relevant content
- Accepted Answerasked 2 years ago
- asked 4 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 4 months ago
- AWS OFFICIALUpdated a year ago
Thanks a lot, it worked, L2 was invoked after I changed the InvocationType to Event in L3
The described L2 behaviour applies also to an SNS. The SNS destination is used only if the L1 request is asynchronous.