AWS SAM CLI

1.158.0 · active · verified Sat Apr 11

The AWS Serverless Application Model (SAM) Command Line Interface (CLI) is an open-source tool that enables developers to build, test, debug, and deploy serverless applications defined by the AWS SAM specification. It provides a local Lambda-like execution environment and integrates with container tools like Docker and Finch for local development. Currently at version 1.158.0, it maintains a frequent release cadence with updates typically occurring weekly or bi-weekly.

Warnings

Install

Imports

Quickstart

This quickstart guides you through initializing a new Python-based 'Hello World' serverless application, building it, testing it locally using `sam local invoke` and `sam local start-api`, and finally deploying it to the AWS Cloud with `sam deploy --guided`. Local testing requires Docker or Finch to be running.

# Initialize a new serverless application (choose 'AWS Quick Start Templates', 'Python 3.x', 'Hello World Example')
sam init --runtime python3.11 --app-template hello-world --name my-sam-app

# Navigate into the project directory
cd my-sam-app

# Build your application (requires Docker or Finch for local container builds)
sam build

# Locally invoke the Lambda function with a sample event
sam local invoke HelloWorldFunction --event events/event.json

# Start a local API Gateway to test your API
sam local start-api

# Deploy your application to AWS Cloud (follow guided prompts)
# Ensure AWS credentials are configured (e.g., via `aws configure` or environment variables)
sam deploy --guided

view raw JSON →