• How to test your AWS code using Moto and Pytest

    Introduction

    AWS’ Boto library is used commonly to integrate Python applications with various AWS services such as EC2, S3, and SQS amongst others. I have generally avoided writing unit-tests for application code that interacts with the boto library because of the complexity involved in mocking and testing these functions.

    However, I recently tried out the Moto library which makes it easy to mock AWS services and test code that interacts with AWS.

    Some of the benefits of using Moto:

    • Testing code that interacts with AWS. Instead of having to test your code in an AWS environment, test AWS interactions locally.
    • Easy to learn and get started with.
    • Extensive coverage of AWS services.

    In this article, we will look at how to add unit tests using Moto.

    Read on →

  • How to build a tool like Zapier using Lambda, SQS & DynamoDB

    Introduction

    Zapier is a no-code workflow automation tool that can be used to integrate apps and make them work together. I have been using Zapier for a bunch of my side projects and it was been pretty useful to hook up services like Stripe with Gmail. However, I recently started hitting their free tier limits and started exploring the possibility of building a simple Zapier alternative, mostly for fun.

    The requirements that I came up with :

    • Completely serverless: I don’t want to manage any infrastructure
    • (almost) Free: It should cost close to $0 for my use-case which I will talk about below.
    • Multi-step workflows: Currently, Zapier’s free tier only lets you perform one action for a particular trigger. I wanted the ability to perform multiple actions (for e.g. send an email and a slack message) for a particular trigger.
    • Webhooks support: I’m a big fan of Zapier’s webhooks functionality and want to replicate that.
    • Polling-based workflows: Ability to poll an API endpoint and take action if there is new data available

    Read on →

  • How to use AWS Lambda & S3 to build scalable & reliable serverless applications

    Introduction

    AWS Lambda can be used to process event notifications from Amazon S3. S3 can send an event to a Lambda unction when an object is created or deleted. This event-driven architecture can be used to build a scalable & reliable serverless applications.

    In this article, we will look at how to build a simple application to create thumbnails of images stored in S3 using AWS Lambda.

    Read on →

  • How to create AWS billing alerts using Lambda, Cost Explorer & SES

    twitter-image

    Introduction

    Amazon provides the ability to create Billing Alarms that can be used to alert whenever your AWS bill exceeds a certain threshold. However, this approach has a few shortcomings:

    • You need to set a predefined threshold. When you are first starting to use AWS, it’s hard to know what your AWS bill will look like. A lot of people set this threshold pretty low to be safe.

    • An alert like this tends to be reactive instead of proactive. The alarm gets triggered once the threshold has already crossed. For example, I had forgotten to turn off an EC2 instance I was no longer using but I only found out about a week later once my billing threshold crossed the limit.

    Cost Explorer does provide an easy-to-use interface that can help keep you on top of your billing data. However, this requires one to use the tool regularly to ensure we don’t miss anything.

    In this article, we will look at how to build a simple pipeline to send us billing reports over email. The generated report will look like this:

    billing-alert-email

    The tools we will use are:

    • AWS Lambda
    • Simple Email Service
    • Cost Explorer API

    Read on →

  • AWS Lightsail Deep Dive: What is it and when to use

    AWS Lightsail doesn’t usually show up in a list of AWS’ most popular services. However, Lightsail can be a great service to use especially if you are looking for a service that is easy to set up and has low maintenance. In this article, we will take a deeper look into Lightsail, when to use it and compare it to some of its competitors.

    AWS Lightsail is a collection of building blocks that make it easy to get a web application up and running pretty quickly. These building blocks are:

    Read on →