AWS Step / Lambda - Storing Variable Between Loops

In my first foray into any cloud computing, I was able to follow Mark West 's directions on how to use AWS Rekognition to process security camera images, which dump into an S3 bucket and provide notification if a person has been detected. Its code was set up for a Raspberry Pi camera, but I was able to adapt it to my IP camera by FTP linking the launched images to my Synology NAS and using CloudSync to flip it to the S3 bucket. The step function calls the Lambda functions in the picture below and I get an email within 15 seconds with a list of labels and an attached image.

Step functions

The problem is that the camera will download one image per second while the condition is triggered, and if there is a lot of activity in front of the camera, I can quickly type a few hundred emails.

I would like to insert a function between make-alert-decision and nodemailer-send-notification that would check if an email notification was sent within the last minute, and if not, go to the nodemailer-send-notification rule and if so, store the list of tags and the path to the attachment in an array, then send one email with all attachments after 60 seconds.

I know that I have to store data externally and came across in this article explaining the benefits of various data caching methods and I also thought that I could check the timestamps of files uploaded to S3 to compare the time elapsed between the two most recently uploaded files to decide whether to continue or batch file later.

Being completely new to AWS, I'm looking for advice on which method makes the most sense in terms of complexity and cost. I can live with the delay associated with any of the methods discussed in the article, I just don't know how to proceed as I have never used or even heard of any services.

Thank!

+3


source to share


1 answer


You can use SQS queue

to which lambda make-alert-decision

sends a message with each label and attachment path.

lambda nodemailer-send-notification

will be the consumer of this queue, but it runs on a regular schedule .



You can specify that the lambda should run every 1 minute by reading all messages from the queue - and immediately removing them from the queue, or setting a suitable visibility time and deleting - to get a list of attachments and send one email. We will have one email with all attachments every 60 seconds.

+1


source







All Articles