All Projects → adnanrahic → lambda-sns-dlq-error-handling

adnanrahic / lambda-sns-dlq-error-handling

Licence: other
Sample project for showing the ability to publish an SNS topic and trigger a function from the topic. Code is structured to create a timeout/crash so the dead letter queue SNS topic gets published, in turn triggering the error handler function.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to lambda-sns-dlq-error-handling

ontopic
Display SNS messages on your terminal
Stars: ✭ 20 (-35.48%)
Mutual labels:  aws-sns
aws-serverless-prototype
Serverless Frameworkを使ったAWS Lambdaプロジェクトの試作品
Stars: ✭ 16 (-48.39%)
Mutual labels:  serverless-framework
a-crash-course-on-serverless-with-nodejs
A quick and easy guide of how to hook up a single Serverless service.
Stars: ✭ 28 (-9.68%)
Mutual labels:  serverless-framework
aws-secure-websockets
Secure web socket implementation using AWS products and serverless framework
Stars: ✭ 49 (+58.06%)
Mutual labels:  serverless-framework
lambdog-server
Write Netlify functions without pulling your hair out.
Stars: ✭ 15 (-51.61%)
Mutual labels:  serverless-framework
lambda-mailer
Simple module for receiving an email from a contact form on your website.
Stars: ✭ 83 (+167.74%)
Mutual labels:  serverless-framework
pexels-demo
A Node JS Express/Serverless demo application that creates a personalised video using a form. Uses the Pexels Video library and Shotstack video editing API.
Stars: ✭ 22 (-29.03%)
Mutual labels:  serverless-framework
serverless-fission
Use Fission through Serverless Framework https://serverless.com
Stars: ✭ 19 (-38.71%)
Mutual labels:  serverless-framework
lockbot
🔒 Coordinate use of your team's shared resources, in Slack 🤝
Stars: ✭ 47 (+51.61%)
Mutual labels:  serverless-framework
serverless-modular
⚡️ serverless plugin for microservice code management and deployment.
Stars: ✭ 19 (-38.71%)
Mutual labels:  serverless-framework
serverlesscloud.cn
Serverless 中文网
Stars: ✭ 15 (-51.61%)
Mutual labels:  serverless-framework
serverless-aws-rust
⚡🏗️ template for new aws lambda serverless rust apps
Stars: ✭ 89 (+187.1%)
Mutual labels:  serverless-framework
serverless-authorizers
Examples to use aws API Gateway authorizer feature to authorize your endpoints with different ways
Stars: ✭ 31 (+0%)
Mutual labels:  serverless-framework
noiiice
a serverless blog built on NuxtJS, AWS, serverless framework, and irrational exuberance.
Stars: ✭ 42 (+35.48%)
Mutual labels:  serverless-framework
serverless-aws-rust-multi
⚡🏗️ template for new aws lambda serverless rust http apps
Stars: ✭ 51 (+64.52%)
Mutual labels:  serverless-framework
amazon-ivs-ugc-web-demo
This repository shows how you can build a compelling user-generated content (UGC) live streaming webapp with Amazon IVS.
Stars: ✭ 14 (-54.84%)
Mutual labels:  serverless-framework
serverless-plugin-offline-kinesis-events
⚡ Serverless plugin that works with serverless-offline to allow offline testing of Serverless functions that are triggered by Kinesis events.
Stars: ✭ 15 (-51.61%)
Mutual labels:  serverless-framework
serverless-swagger-api
Simplifies the process of generating an API Gateway API from a swagger file.
Stars: ✭ 15 (-51.61%)
Mutual labels:  serverless-framework
EventBus
A .NET Core ultra lightweight in-memory event bus implementation.
Stars: ✭ 73 (+135.48%)
Mutual labels:  aws-sns
fastapi-mangum-example
Deploy FastAPI as Lambda using serverless and mangum
Stars: ✭ 21 (-32.26%)
Mutual labels:  serverless-framework

Trigger AWS Lambda with SNS with DLQ error handling

Sample project for showing the ability to publish an SNS topic and trigger a function from the topic. Code is structured to create a timeout/crash so the dead letter queue SNS topic gets published, in turn triggering the error handler function.

Explanation

  • The init function is the only exposed function, which is hooked up to API Gateway. It takes a single number parameter which it validates, upon success it publishes an SNS topic and sends along the number value.
  • The SNS topic will trigger a second function called calculate. This function will perform the calculation and log out the result to the console. This mimics a heavy computational background task such as data processing, image manipulation or machine learning calculations.
  • If either of the two functions fail the dead letter queue SNS topic will receive a message and trigger the error function.

Every function will try to retry its execution upon failure a total of 3 times. Using the dead letter queue as a pool for your error logs is a smart use-case.

Causing a crash

Adding a crazy huge number will trigger a factorial calculation that'll crash because of a Maximum call stack size exceeded rangeError.

curl -H "Content-Type: application/json" \
  -d '{"number":10000000}' \
  https://<id>.execute-api.<region>.amazonaws.com/dev/init

This will trigger the error function where you can handle the error as you wish.


The service is only a basic proof of concept which shows the use case of SNS triggering lambda functions and dead letter queues. The actual code is trivial and not exciting at all, but it serves the sole purpose of explaining what the *@$# is going on. 😄


TODO

  • add SQS resources
  • create setup where DLQ uses SQS
  • create stream between init and calculate with SQS
  • add SSM params instead of secrets.json
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].