The AWS Serverless Application Model (SAM) is an open-source framework for building serverless applications. Using YAML, you can leverage SAM’s shorthand syntax to express functions, APIs, databases, and event source mappings. When you deploy SAM template(s), the shorthand syntax is transformed to AWS CloudFormation syntax.

 

What is a Serverless Application?

A Serverless Application is more than just a Lambda function. It can include resources like APIs, databases, and event source mappings.

 


Key Components of AWS Serverless Application Model (SAM)

 

SAM Template

SAM template is a basically a YAML configuration, and is the key component of SAM that you work with.

  • This Template is where you define all AWS resources that are part of your Serverless application
  • The following example shows a YAML-formatted template fragment.

Serverless Application Model Template

 

SAM CLI

As the name suggests, SAM CLI is simply command line interface tool that enables you to run associated commands such as to initialize SAM, build, test, debug and deploy Serverless applications.

 


Key Points

  • SAM is built on top of CloudFormation.
    • The format of an AWS SAM template file closely follows the format of an AWS CloudFormation template file, with some changes that streamline it specifically for Serverless applications.
  • You work on SAM through its Command Line Interface (SAM CLI).
  • SAM CLI supports local building and testing the Serverless applications.
  • SAM CLI supports local debugging of Lambda functions written in Node.js, Java, Python, and Go.
  • SAM supports integration with many popular IDE tools.
  • Both SAM and SAM CLI are open-source, and you can view or contribute to source code:
    • SAM: https://github.com/aws/serverless-application-model
    • SAM CLI: https://github.com/aws/aws-sam-cli

 


Pricing

There is no charge for using SAM or SAM CLI. You pay for the resources created using SAM based on resources’ pricing.

 


Also see:

 

External Resources

 

Just in case if you are wondering what’s Squirrel doing on this article – this is SAM the Squirrel, named after AWS SAM.