Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
April 15, 2023 03:00 pm GMT

AWS Mini-Project - Cats Need Love Too

Completed my first AWS Mini Project today. The services used were DynamoDB, Lambda, and SNS.

I first created a DynamoDB table where I manually entered in fictional data for a cat adoption agency. I entered in 8 kittens, their names and adoption statuses. In a real world example this would have been populated from a front-end website. In an ideal world all cats would have homes with all the cat nip and sunlight a kitten could dream of.

Image description

After creating my table I explored the comparison of querying the data in the table versus running a scan of the existing records. Querying the data appears to be more efficient, eliminating the need for DynamoDB to iterate over every record, however I will use scanning later in the project.

Next I set up an SNS email protocol. In simple terms AWS SNS is a messaging service that will allow me to send messages and notifications to any subscribed member in my cat loving community that is interested in adopting a cat. In this example they will be receiving updates when a cat is adopted encouraging them to hop onto the site if they want to adopt one before they are all gone.

Image description

Now onto creating the Lambda function, which is named cat-adoption-function. In this portion I inserted code that will iterate through all the cat records that Dynamo DB passes to the Lambda function, and then publish the message for our subscribers to receive.

Image description

Image description

Next, I gave the Lambda function created permission to access DynamoDB so it can read the data from the DynamoDB Stream. Without this permission, the function created will not work.

Next, I enabled the DynamoDB Stream that will trigger that cat-adoption-function every time a cat's adoption status is changed to true.

The final step involved testing it out. In the DynamoDB console I ran a scan to ensure the code is working as expected and that the Lambda function is correctly reading and processing all of the table items. At the initial scan all of the adoption statuses were set to false. In a real world example this testing phase will be crucial to identify any data insertion, bug, and performance issues that could occur with larger datasets.

Image description

To test the trigger, I changed the adoption status of one of the cats to true in the DynamoDB table. Upon making the status change I received an email notifying me that the cat selected has been adopted!

Image description

As best practice with all projects, my final step involved cleaning up, by deleting all the resources used in this project.

And voila! There goes my first project, looking forward to the next. Shout out to my favorite AWS course that is helping develop these skills and support my learning with these projects: adrian cantrill

Cover Photo by The Lucky Neko on Unsplash


Original Link: https://dev.to/zyounger8/aws-mini-project-cats-need-love-too-5hi2

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To