Getting started with SNS (use SnS for push notifications)
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 old
pub-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.
Jump Here
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
Serverless As Defined By Serverless Folks (Here)
The Serverless Framework helps you develop and deploy your AWS Lambda functions, along with the AWS infrastructure resources they require. It’s a CLI that offers structure, automation and best practices out-of-the-box, allowing you to focus on building sophisticated, event-driven, serverless architectures, comprised of Functions and Events.
A few things the Serverless Framework does differently than a normal application Framework are:
- It manages your code as well as your infrastructure
- It supports multiple languages (Node.js, Python, Java, and more)
- It supports FaaS on Azure, AWS lambda and other similar providers
- Here are the Framework’s main concepts and how they pertain to AWS and Lambda…
For more verbose information on same , This is the best place to lookup. We’d rather focus on building something up below
What Serverless is and what it isn’t ?
- Serverless is a framework for FaaS providers. It is not a FaaS provider itself
- It helps organize code and prepare it for deployment onto FaaS infrastructure(like AWS Lambda)
Steps to building with serverless
- install serverless globally
npm i -g serverless
- install
nvm
and be on v4.3 of node (supported by AWS lambda at the moment) - clone from starter repository -
https://github.com/saurshaz/serverless-starter
- change code as needed,
cd lambda
- test it offline (using
serverless-offline
plugin). usesls offline
- deploy the function(s) by doing
sls deploy
- The endpoint URL you see is the one you can connect to by hitting via
http
(remember though that the lambda is invokable not just via tcp/http calls but can be scheduled triggered viasns
also) - For example, in above -
https://yqmemur7n0.execute-api.us-east-1.amazonaws.com/dev/hello
is the URL that can be hit
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]: