Table of Contents

About

The AWS Serverless Application Model (AWS SAM) is an open-source framework that you can use to build serverless applications on AWS.

Cli

With the AWS SAM CLI, you can invoke Lambda functions locally, create a deployment package for your serverless application, deploy your serverless application to the AWS Cloud, and so on

Local Serverless AWS testing (SAM)

Code for AWS Lambda functions is delivered to the service by uploading the function code in a .zip package to an Amazon S3 bucket. The SAM CLI automates that process for us. Using it, we can create a CloudFormation template that references locally in the filesystem where all of the code for our Lambda function is stored. Then, the SAM CLI will package it into a .zip file, upload it to a configured Amazon S3 bucket, and create a new CloudFormation template that indicates the location in S3 where the created .zip package has been uploaded for deployment to AWS Lambda. We can then deploy that SAM CLI-generated CloudFormation template to AWS and watch the environment be created along with the Lambda function that uses the SAM CLI-uploaded code package.

Lambda Doc

Install

Install doc

Requirement:

  • Docker installed and running to be able to run serverless projects and functions locally with the AWS SAM CLI. The AWS SAM CLI uses the DOCKER_HOST environment variable to contact the Docker daemon.
  • For Windows users: The AWS SAM CLI requires that the project directory (or any parent directory) is listed in Docker Shared Drives.

Installation mode:

  • With pip:
:: install
pip install --user aws-sam-cli
:: or upgrade
pip install --user --upgrade aws-sam-cli
:: or uninstall
npm uninstall -g aws-sam-local

Verification:

sam --version
SAM CLI, version 0.14.2

Specification

The AWS SAM specification is an open-source specification under the Apache 2.0 license. The current version of the AWS SAM specification is available in the AWS SAM GitHub repo.