1

Context

I have 2 SNS both publishing messages with different data model. I want a lambda to get these messages and do some processing. Creating a SQS between the SNS and Lambda is mandatory.

What i thought of?

I will create 2 new SQS to subscribe to the 2 SNS. One SQS will subscribe to only 1 SNS. I will create 2 new Lambda to read from 2 SQS and process the messages.

What i am looking for ?

Is there a way to create only 1 SQS and subscribe to both SNS and create 1 Lambda to read from the 1 SQS. Asking this because creating 2 lambda and SQS is costly. The major issue is both SNS have different data model. Is there a way to overcome this ?

1 Answer 1

3

You can have both topics deliver their messages into the same Queue and then use a single Lambda to read from that.

If you disable raw message delivery (docs), the Event will include information about the topic the Event is from, which allows you to distinguish between the two event types in your Lambda code and handle them separately.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.