I’ve been using the Serverless Framework for around 2 years now. I not only use it for deploying Lambda functions and APIs, complete sets of infrastructure too and prefer it to AWS’ SAM. Although under the hood it mostly uses CloudFormation (like SAM), the way it orchestrates packaging of code for Lambda, then joining the dots automatically for API Gateway (and other event sources) makes deploying serverless applications incredibly simple.
More recently, AWS has been making waves with Amplify, which has made deploying applications end to end very simple by asking what you want to do, such as adding hosting or authentication, without needing to worry about the how part. I was excited to see Serverless release “Components”, as it looks to make some of the more complex or custom parts of deploying infrastructure simpler by building for use cases, and in some ways could be considered as a basic competitor to Amplify.
There are currently several components available, with the ability to build your own, but let’s take a look at something relatively common — deploying a website to S3 and CloudFront. Before serverless components, I would have to add custom resources to my template, which looked similar to below:
Even after 71 lines of code you still need to have created a certificate in ACM, built your react app, and then deployed it to the S3 bucket. The same thing using the new serverless components looks like this:
With components, we can create the same infrastructure in around 6 lines, 92% less! It even creates our certificate, builds and deploys our web application as well. If you were to take it another step further, you can deploy DynamoDB databases in just a few lines or a RESTful API as well, which brings me to my next point — Serverless says: