Automate chores — be happy — repeat

djangsters
3 min readFeb 22, 2023

Scheduled or just repetitive tasks tend to feel like chores, sucking out creativity and inspiration. Regardless they still have to get done. As software developers we are not an exception in having such tasks, but we have something up our sleeve — namely skills to automate! Not only will automated tasks free up our mental capacity for challenging and creative activities, but also we will surely have fun programming the automation itself.

Being an IT consulting agency we send reports to our clients with the billed time we spent working on their projects. Different clients require different frequency of reports as well as different levels of detail. We used to handle this task manually by generating a customized report as a XLS/PDF/CSV file from the time tracking software, writing an email with the attached report file and sending it to the client. While not being a complex task on its own, it definitely felt like a chore, especially for weekly emails. Without hesitation we decided to automate that process.

As we are talking about at most weekly events, we immediately looked in the direction of AWS Lambda for the service to run on. For such a small project we were very happy not to have to manage any infrastructure, and with the AWS Lambda pricing model we even stayed within the free tier. Can it get more attractive than that?

Luckily our time tracking software offered API endpoints to programmatically generate reports. The only business logic we had to write was a function that determined start and end dates for weekly date ranges. That’s it, the report part was done.

Amazon Simple Email Service covered us for email sending. During the development phase we could immediately use the service in the sandbox mode, meaning we could send emails only from and to verified email addresses. As soon as we were ready to go to production, we were quickly granted production access, and no recipient email verification was needed anymore.

For scheduling we used Amazon EventBridge, which supports simple rate or more complex and versatile cron expressions, with which one can cover basically every schedule imaginable.

Functionally the service was complete. Just one thing was missing — monitoring. With automation it is very important to know if something goes wrong. There is no point in automating something, but still have to manually check whether the automation keeps working fine. And yet again, we got happy about our choice of AWS Lambda as Lambda functions are automatically monitored through Amazon CloudWatch.

We use Slack for all of our work communication, so an alarm notification into a dedicated Slack channel in case of a failure was a great idea for our team. In the past we used to use AWS Lambda to power the notification service from CloudWatch to Slack. However it felt like an overkill to create a Lambda function to notify about a failure in another Lambda. Luckily now Slack has what it didn’t have before — workflows, triggered using a webhook, with the ability to parse JSON outputs by defining variables. This all together allowed us to post notifications to Slack with Amazon Simple Notification Service in case of a CloudWatch alarm without any extra service in between.

And now the automation is done! The service has been running for over a month now and we’ve been nothing but happy about the decisions we made along the way. Take time to evaluate your tasks and automate the ones you can. We surely will.

Originally published at https://www.djangsters.de on February 22, 2023.

--

--

djangsters

djangsters are human-friendly IT professionals, who develop web applications, tailored to the individual needs of their customers. https://www.djangsters.de