using serverless framework vs sam cli for aws 1

SAM CLI – Serverless Application Model , is a command line tool provided by AWS to easily create and manage serverless applications.

Serverless Framework – Serverless Framework is also a tool similar to SAM but it is not limited to AWS, Serverless Framework can be used to easily create and manage serverless applications from various providers like AWS, Azure, GCP & more.

I will list the main differences I found between these two when used with AWS, which may help you to choose between them.


You need to follow operating system specific installation steps as there are multiple dependencies for SAM which are installed differently on different operating systems. Below are some general steps to be followed irrespective of operating system.

  • Create an AWS account.
  • Configure IAM permissions.
  • Install Docker. Note: Docker is only a prerequisite for testing your application locally.
  • Install Homebrew.
  • Install the AWS SAM CLI.

For Serverless you need to follow operating system specific instructions only for installing Node.js and if you have Node.js installed on your machine already, then using single command below your Serverless installation will be ready ‘npm install -g serverless’.

  • Install Node.js
  • Install Serverless (npm install -g serverless)

Resource Definition


SAM being an AWS specific framework, it supports managing most of the AWS resources out of the box and you can expect it to be always in sync with AWS service updates.

  • Resources are defined in a file called template.yaml
  • More verbose hence produces more lines of code compared to serverless
  • Resources are created and managed by a cloudformation stack Eg: Defining an API Gateway endpoint in SAM
    Type: Api
    Path: /items
    Method: GET

Serverless being a generic framework for multiple serverless platforms , it may not support all AWS services and it will always take some time to get the latest updates with respect to changes in latest AWS services.

  • Resources are defined in a file called serverless.yml
  • More readable and less code compared to SAM
  • Resources are created and managed by a cloudformation stack
    Eg: Defining an API Gateway endpoint in Serverless
    path: /items
    method: GET

Local Development


Can simulate API Gateway and Lambda locally without require any extra dependencies and these two services are the most common requirements to run a serverless application in AWS.


Need extra plugins to be installed for most of the basic requirements like local development server, creating nested stacks, etc.



On initial versions of SAM we had to run 2 different commands to build, upload and deploy and it did not support features like one step deployment and automatic deployment bucket creation which was supported in serverless framework at the same time. The Latest version of SAM supports single command deployment similar to Serverless.


We can deploy using single command ‘sls’ deploy and S3 bucket creation is taken care automatically, we can also deploy or update single function in a stack individually which is not supported by SAM.


Serverless and SAM both have pros and cons based on the various scenarios in which they are used , so based on these observations , it is better to go with SAM if you are a developer who works only with AWS cloud. It is better to choose Serverless framework if you are a full time devops engineer or cloud developer who will be managing and working with different serverless providers at the same time. This gives you the advantage of a single framework, access to a vast community, and readily available documentation.

We at techpearl have exposure to various technologies and frameworks. We will pick the framework that fits most conductive to your needs. Contact us to learn more.

Read More Articles

 Contact Us Now

Talk to us to find out about our flexible engagement models.

Get In Touch With Us