By using AWS re:Post, you agree to the Terms of Use

Lambda Events not triggering EventBridge destination

1

I am using the Amazon Selling Partner API (SP-API) and am trying to set up a Pub/Sub like system for receiving customer orders etc.

The Notifications API in SP-API sends notifications of different types in 2 different ways depending on what event you are using. Some send directly to eventBridge and others are sent to SQS. https://developer-docs.amazon.com/sp-api/docs/notifications-api-v1-use-case-guide#section-notification-workflows

I have correctly set up the notifications that are directly sent to eventBridge, but am struggling to work the SQS notifications. I want all notifications to be send to my own endpoint.

For the SQS model, I am receiving notifications in SQS, which is set as a trigger for a Lambda function (This part works). The destination for this function is set as another eventBridge (this is that part that doesn't work). This gives the architecture as: SQS => Lambda => eventBridge => my endpoint

Why is lambda not triggering my eventBridge destination in order to send the notifications?

Execution Role Policies:

  • Lambda
    1. AWSLambdaBasicExecutionRole
    2. AmazonSQSFullAccess
    3. AmazonEventBridgeFullAccess
    4. AWSLambda_FullAccess
  • EventBridge
    1. Amazon_EventBridge_Invoke_Api_Destination
    2. AmazonEventBridgeFullAccess
    3. AWSLambda_FullAccess

EventBridge Event Pattern:

{"source": ["aws.lambda"]}

Execution Role Trusted Entities:

  • EventBridge Role "Service": [ "events.amazonaws.com", "lambda.amazonaws.com", "sqs.amazonaws.com" ]
  • Lambda Role "Service": [ "lambda.amazonaws.com", "events.amazonaws.com", "sqs.amazonaws.com" ]

Lambda Code:

exports.handler = function(event, context, callback) {
   console.log("Received event: ", event);
   context.callbackWaitForEmptyEventLoop = false
   callback(null, event);
   return {
      statusCode: 200,
   }
}
1 Answer
1
Accepted Answer

If you are using Lambda Destination to trigger EventBridge that will not work. The reason is that Lambda Destinations works only for Asynchronous invocation. In the case of SQS -> Lambda it is an Event source mapping invocation, which under the hood uses Synchronous invocations.

If you need to send an event to EventBridge, just send it from your Lambda code.

profile picture
EXPERT
answered 5 months ago
  • Thank you, I have now managed to get it working using the lambda script.

  • This seems to contradict the documentation on Destinations [1]: "Previously, you needed to write the SQS/SNS/EventBridge handling code within your Lambda function and manage retries and failures yourself."

    If I hard-code the EventBridge details into my Lambda, what does the Destination configuration do?

    [1] https://aws.amazon.com/blogs/compute/introducing-aws-lambda-destinations/

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions