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
- AWSLambdaBasicExecutionRole
- AmazonSQSFullAccess
- AmazonEventBridgeFullAccess
- AWSLambda_FullAccess
- EventBridge
- Amazon_EventBridge_Invoke_Api_Destination
- AmazonEventBridgeFullAccess
- 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,
}
}
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/