DEV Community

Cover image for How I built an automated event-driven app
Phaustin Karani
Phaustin Karani

Posted on • Edited on

How I built an automated event-driven app

I recently was working in my kitchen garden pondering how I could automate some tasks like setting reminders to water/mulch the plants when an idea struck me. To that point, I relied on my brain to remind me to water my plants and since life gets busy sometimes I ended up forgetting my duties greatly hurting my plants.

After a short brainstorming session I knew that I could build an automated system that could send me notifications via text/email I just didn’t know how to put all of them together.

I know some of you are wondering why I didn’t consider using Google Calendar reminders which can set reminders easily. I needed a system that I could add more features in the future like integration with IoT sensors that measure humidity and soil PH features that can't be done with a calendar app.

Being a regular AWS user I knew that they had all the solutions I needed for my build I just needed to research how to put them together.

How I Built My Serverless App

After hours of research, I settled with AWS Lambda, Simple notification service and Amazon Event Bridge. I tried to work with Cloud Watch alarms but I realized it didn’t fit my build, Amazon Event Bridge which was separated from Cloud Watch has features like scheduling that fitted my solution perfectly.

Image description

Aws Lambda being serverless and compatible with common programming languages helped a lot. I deployed a Python function that could publish messages to an SNS topic that I had already created. the function initially failed when I tested because it didn’t have the necessary permissions, I asked Amazon Q for the permissions that were necessary for it to be able to publish and headed to IAM and attached the necessary role to my lambda function.

 Amazon Q  is a revolutionary generative AI product like Duet AI in Google Cloud which helps in shortening the time you would consume reading through documentation by giving you summarised versions of documents in seconds.

Image description

as I mentioned earlier I used the AWS event bridge scheduler which is a serverless scheduler that allows you to create, run, and manage tasks from one central, managed service. I created a recurring schedule since this is an event that will be happening from time to time but you can also create a one-time schedule.

Image description

I then created a cron-based schedule because I needed it to run at specific times and dates, I then selected my lambda function as the target API that will be invoked by my schedule but you have the option to call common services like run tasks on ECS, put records on kinesis data streams and start a build on Code build among others AWS APIs.

after publishing my schedule it invokes the lambda function during the scheduled time and the Lambda function publishes a message on the SNS topic which sends me an alert.

Image description

what next for the event-driven app

as I indicated earlier I used AWS because of the many features I can roll out in the future that aren't available in calendar schedules. I am looking forward to adding SMS notifications and also integrating with sensors to enable smart farming practices.

Top comments (0)