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개 답변
1
수락된 답변

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 pictureAWS
전문가
Uri
답변함 2년 전
profile picture
전문가
검토됨 한 달 전
  • 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/

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠