It’s hard to believe that Lambda function have already been around only for the last 5 years (at the time of writing this), and it became so popular so quickly.
I’ve been working as a DevOps engineer for the last 8 years or so (working on AWS for the last 7 years), and I wanted to review some of the tools I came accross for deploying serverless solutions on AWS.
I. First wave: bash script
It works! And it still does, although it’s not very scalable, it’s mainly (as I still does today) for installing dependencies, testing and packaging them into zip.
One example of bash script code I keep re-using is this one:
This is working quite well for the first part (Continuous Integration) but doesn’t fit the second part (Continuous Delivery). Back in these days, I started using CloudFormation for CD requirements, let’s see an example.
II. Cloudformation Area
Around 2016, a Cloudformation allowed the use of Yaml format for declaring AWS resources, that was a massive change specially for the sake of my eyes
From this to this:
Declaring AWS Lambda functions for Operational purposes, Cloudformation was indeed doing the job. Unfortunately, it can become rather complexe if you start adding API Gateway / SNS Topics and so on to the equations:
This is a truncated example of an API Gateway declaration in Cloudformation format 😅. Let’s see Terraform way
III. Does Terraform make it better?
Depending who you ask, I believe it slightly does but not that much:
AWS: aws_api_gateway_integration - Terraform by HashiCorp
Provides an HTTP Method Integration for an API Gateway Integration.
Based on my experience, I had trouble deploying AWS Lambda functions with Terraform, especially around Stages and Testings which would see later. Terraform seems to have issues picking up the latest zip file containing the source code (even when build locally), I had to ran it twice
IV. AWS SAM
Around 2018, AWS introduced AWS Serverless Application Model to answer the needs for managing Serverless deployments and the management of them. SAM is simply an extension of CloudFormation, is also using Yaml format and the installation process is as simple as AWS CLI one:
pip install aws-sam-cli
SAM CLI is then available as
sam. Once completed, let’s crack on the first step: Package
sam package \
--template-file template.yml \
--output-template-file package.yml \
This command is to upload any artifacts to an AWS S3 bucket.
V. Serverless Framework
More to come…
VI. What next?
More to come…