Search code examples
amazon-web-servicesserverlessaws-sam-cli

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?


Solution

  • 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.