AWS Certified Solutions Architect - Professional 2020

Sign Up Free or Log In to participate!

Why not use SNS instead of another Lambda Function to fan out?

Just wondering if there is a reason.

2 Answers

One of the general concepts of serverless is not building yourself a tool when you can use one that’s already available for you. 

Could you write your own function that does the exact same thing as an SNS topic?  Sure.  

How long will that take for you to code?  To test?  To fix?  To adjust to scale?

famarant

Sorry, I think I wasn’t clear enough. In the diagram it shows a Lambda Function fanning out and not SNS. Just wondering if there is a specific scenarion that you should use lambda over sns for that. As far as I know… none.

Steven Moran

Hmm. I’ll need to see if I can find that diagram. What is the Lambda function fanning out to?

Gabriel Vince

It’s time 3:34 , there’s an "Image Receipt" lambda invoking other lambdas, that may be an issue as the lambda is doing several non-transactional updates. You may have this architecture assuming the consumers are idempotent

In the case of the lesson I found this question on (Lambda, Serverless Application Model and EventBridge in the CASP course), the originating source of the data to the Lambda function was SQS so that provides a set of requirements on how the data is retrieved.

You can create Lambda triggers for SQS queues that will automatically run the specified Lambda function(s) but there is not a direct way to send data from SQS to SNS.

On the flip side, you can subscribe SQS to an SNS Topic and have the data from SNS sent to SQS automatically but that’s not really the point of your question.

Regardless, you would need something to retrieve the data from SQS and then send it to SNS which you would do with the Lambda function. But if you’re going to do that, then there is little sense in adding the extra step to "fan out" using SNS as the Lambda function can take care of that with a little extra code.

Additionally you may want to modify or format the content that will be sent to the receiving application(s) which a Lambda function is more suited for than a SNS Topic.

Does that help?

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?