AWS CDK constructs with Serverless Framework - introduction

By Daniel Aniszkiewicz ยท 15 June, 2021

Introduction

The AWS CDK is an open-source framework backed by the AWS, which allows you to define your cloud infrastructure using programming languages (IaC). Unfortunately at this moment, AWS CDK does not support the Ruby language. It does support the following languages.

AWS CDK Constructs define a piece of the desired state of cloud applications. Usually construct is a class, and can either consist of a single AWS resource, such as SQS/SNS/S3, or consists of multiple AWS resources, all through AWS CloudFormation. At the same time, it is a very powerful concept, and on the other hand, it is very complicated. There are some nice examples of already defined constructs, you can check them out here and here.


The Serverless Framework itself, on the other hand, does not allow you to use CDK Constructs. However, a plugin has been created that allows using parts of Constructs inside of Serverless Framework.


General content

This plugin is named Lift. It is written in Typescript and allows you to use AWS Constructs inside the Serverless Framework literally in a few lines.


At the moment there are only a few supported use-cases, but in the near future the authors of the plugin will work hard on it, so it is worth being interested in this plugin. The current progress could be found here.


As of today, we have 4 use cases:


  • Static website (deployment of a static websites and SPA).
  • Storage (S3).
  • Queue (SQS).
  • Webhook (notifications from the 3rd party apps).
Static website construct

features

More info about static construct here.


Storage construct


features

More info about storage construct here.



Queue construct
features

More info about queue construct here.


Webhook construct

features

More info about webhook construct here.


A very cool aspect is the eject. In case your project grows beyond the plugin, you can eject from Lift at any time, as the plugin is based on CloudFormation. You're not chained to Lift at all.


Summary

Lift looks very promising. The project is in development, you can submit your own comments/ideas for the next constructs. You don't need to have experience with AWS CDK to use them, and they solve several different use cases that we have every day in web application development.

If the AWS CDK doesn't support your programming language but you'd still like to use it, through Lift you have a chance to do so. In the next post we will create a project using this plugin.