Proactivity

Getting Started Using SnS To Connect Lambdas (use SnS to connect lambdas)

Source

This post covers an introduction AWS Simple Notification Service (AWS SNS). It will cover (as an example) the was SNS can be used to connect two different lambdas and how one can trigger the execution of the second lambda.

_aws-lambda getting started & example_


What is AWS SNS ?

Best described here as Fully managed and highly scalable push messaging. I have understood(being a developer) as - It is the good oldpub-subfor your AWS infrastructure services. What works for SNS as a lucrative offering is -

  • It is AWS offering
  • It is incredibly cheap for your next app. Your first 1 million Amazon SNS requests per month are free, then it costs $0.50 per 1 million Amazon SNS requests thereafter.
  • Much needed pub-sub glue for different AWS infrastructure services
  • Also usable for Push notifications (we’ll cover this in [SNS part two][3])

Serverless is an MIT open-source project, actively maintained by a vibrant and engaged community of developers.
AWS Lambda

Serverless is tragetting a broader vision/concept - to become a framework for different FaaS providers (not just AWS Lambda)

Serverless Framework - Build applications on AWS Lambda, Google CloudFunctions, Azure Functions, AWS Flourish and more

For more verbose information on Serverless

The Code I use to explain the setup

The code I’m using is at github
This is mostly work altready done by at
Feel free to extend the chain

Steps to using SNS + AWS Lambdas with serverless

  • install serverless globally npm i -g serverless
    Make sure that you use Serverless v1.(have serverless installed globally)
    Stay on Node version 4.3
  1. Run serverless install --url https://github.com/saurshaz/serverless-sns-lambda-chaining to install the service in your current working directory
  2. Next up cd into the service with cd serverless-sns-lambda-chaining
  3. Run npm install
  4. Copy .env.sample into .env. Replace the ACCOUNT_ID in the .env file with your AWS account id
  5. Deploy with serverless deploy
  6. Invoke the first function via the endpoint (you’ll see the endpoint in terminal, when deploying)
  7. Notice cloudwatch logs to verify second lambda also gets invoked. that happened via SNS

Logs will show something like this - image

Any Limitations ?

Well, AWS Lambda is pretty flexible and allows you to explore any code capable logic uploaded and running on AWS. However, it expects the functions to be under a specific size

AWS Lambda Deployment Limits

  • Lambda function deployment package size (.zip/.jar file) 50 MB
  • Size of code/dependencies that you can zip into a deployment package (uncompressed zip/jar size) 250 MB
    AWS limitations

[3]: