Introduction

Nowadays many Infrastructures as Code tools are available for building cloud applications, for example, Serverless Framework (Most Widely Used) and AWS CDK (Fastest Growing) are both popular choices. In this article, we will take a look at the differences between Serverless Framework and AWS CDK.

What is IaC (Infrastructure as Code)?

IaC (Infrastructure as Code) is the provisioning of infrastructure using code instead of manually creating resources. Infrastructure specification handling at the code level becomes easy through IaC frameworks. Furthermore, IaC helps with automating infrastructure provisioning, so the developer does not need to manually create and manage cloud infrastructure resources during application deployment.

What is Serverless Framework?

Serverless Framework is a widely used open-source IaC tool that allows you to build, and deploy serverless applications on multiple cloud providers. Serverless Framework supports infrastructure code specifications in YML file format (e.g serverless.yml) and transforms that into a specific cloud provider-supported template format.

Source

What is AWS  CDK (Cloud Development Kit)?

AWS CDK (Cloud Development Kit) is an open-source software development tool and is the fastest-growing framework to define AWS cloud infrastructure in code. It provisions itself through AWS CloudFormation.

Source

Difference Between Serverless Framework and AWS  CDK

Links: Plugin, Construct, Github 1, Github 2
Links: Serverless Framework, AWS Getting Started

Serverless Framework IaC YML Example - AWS Lambda Deploy

AWS CDK IaC JavaScript Example - AWS Lambda Deploy

Install node module for lambda: npm i @aws-cdk/aws-lambda

Conclusion

Serverless Framework and AWS CDK are both good tools for Infrastructure as Code management, but which should I use? There is no comparison of which is better over the other, since each framework has its own strengths and capabilities that make developer life easier. This means that the framework you should choose is the one that works best for your project use cases and team.