I have seen many examples where people have used Lambda and SNS to send notification to user if anything new is added to the DynamoDB table..but how can this be done using NodeJS. Requesting for some insightful resources.
1 Answers
I think what you're looking for is called DynamoDB Streams
. You can dig deep into the documentation for better understanding. The primary idea here is to create something known as a stream
on a particular table
and attach a Lambda
trigger to it.
You can write the Lambda
code in javascript
and deploy it on a NodeJS environment in AWS Lambda Service. This way whenever there is a new record or update in a particular record in your table, the stream
will automatically inject the whole record as a JSON
object into your lambda, which you can then process and leverage SNS
for sending out a notification.
Tutorial:
Tutorial: Process new items with DynamoDB Streams and Lambda
Using NodeJS hosted on your server:
If you wish to skip AWS Lambda
and use pure NodeJS
hosted on your server, you could probably make use of SQS
queues. So instead of having the Lambda trigger directly sending out the notifications, you can just add them to a notification queue. You can consume this queue using AWS SDK for JavaScript v3 (i.e AWS.SQS()
) and then you can send a notifications using AWS.SNS()
from your NodeJS server.
Advanced approach:
If you're advanced level developer, then you could even use the DynamoDB Streams Kinesis adapter
to process stream records with the API calls. I've personally never used this approach, but attaching a link here for your reference.
References:

- 4,018
- 1
- 7
- 19
-
Thank you...can you recommend how to advance my learning in Lambda and API's – Devansh Goel Nov 17 '22 at 22:18
-
[Lambda Guide](https://docs.aws.amazon.com/lambda/latest/dg/welcome.html), [API Gateway Guide](https://docs.aws.amazon.com/apigateway/latest/developerguide/welcome.html), [Udemy Course](https://www.udemy.com/course/aws-lambda-api-gateway-training-course/) – Salvino D'sa Nov 18 '22 at 00:17