6

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?

Osama AbuSitta
  • 3,918
  • 4
  • 35
  • 51
Simon Taylor
  • 607
  • 1
  • 9
  • 27

1 Answers1

3

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.

Ellery
  • 1,356
  • 1
  • 14
  • 22
  • Your comment implies that AWS SAM running locally does not natively support SQS, is that true? By "support SQS" I mean provide a local environment separate from AWS hosted/provided infrastructure, which emulates SQS and allows lambda's executing locally in AWS SAM to use the local SQS emulation/implementation. – MattG Oct 01 '20 at 01:43
  • https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-command-reference.html is the sam reference, i don't see anything in here that implies it natively supports SQS and from what I can tell in my own testing (and what brought me to this question) is that it does not. Looks like you can trigger the events to your lambdas locally though but having a function write to sqs is going to expect a deployed queue, just like local writing to dynamo will write to your deployed dynamo. – hurlbz Apr 22 '21 at 14:48