Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Serverless or SAM and local development with SQS, SNS, and APIGW

I am evaluating serverless v AWS SAM CLI. I am trying to understand how can i facilitate a local dev workflow when developing using the following:-

  • Lambda’s written in python
  • Triggered by SNS notifications with an SES mail payload
  • Reading S3 objects
  • Reading and writing dynamodb
  • Writing to SQS
  • Writing to SNS topic

I can see from the doc that serverless has local options for:-

  • S3
  • DynamoDB
  • SNS events inbound

Not obvious if there is a solution for:-

  • API Gateway local supporting python lambdas
  • Writing to SQS
  • Writing to SNS

I can see from the SAM doc that its possible to test python Lambdas against local DynamoDB. Not clear what else is possible or if you have to point it to a an actual AWS instance for the rest (S3, SQS etc)

Any pointers?

like image 398
Simon Taylor Avatar asked May 11 '18 10:05

Simon Taylor


People also ask

What is the difference between AWS SNS and SQS?

AWS SNS is a publisher subscriber network, where subscribers can subscribe to topics and will receive messages whenever a publisher publishes to that topic. AWS SQS is a queue service, which stores messages in a queue.

Is Amazon SQS serverless?

SQS provides queues for your serverless applications. You can use a queue to send, store, and receive messages between different services in your workload.

Is Amazon SNS serverless?

SNS works with Serverless in three ways. First, you can configure an SNS event in your Serverless function. This uses the integration between AWS Lambda and SNS and runs your Serverless function for each message (or group of messages) that is sent to the SNS topic.

Should I use SQS between SNS and Lambda?

Having SQS in between SNS and Lambda allows reprocessing older unprocessed events in case Lambda fails to process. SQS allows to put a delay, so that message gets processed after some time, it may be useful in the scenario where data takes time to be available.


1 Answers

I would look into leveraging something like https://github.com/localstack/localstack to achive SQS and SNS.

For APIGW endpoint this is built into sam-cli in your SAM template using the Events param on your function resource or using API resources. See API section in following link https://docs.aws.amazon.com/lambda/latest/dg/serverless_app.html

Although it does not have complete functionality yet so it might not have everything you need like request body validation for example. I usually find I can do most of my app testing locally with this before deploying and doing more integration testing in real env.

like image 198
Ellery Avatar answered Nov 13 '22 08:11

Ellery