Open-source command-line tool for developing serverless apps with AWS SAM: scaffold projects, build Lambdas, test locally, sync to AWS, and deploy CloudFormation stacks.
Overview
The AWS Serverless Application Model CLI is a command-line companion for serverless work on AWS. It targets applications built from Lambda functions, API Gateway, Step Functions, EventBridge, queues, topics, and related resources defined in SAM or CloudFormation templates.
`sam init` scaffolds new projects from AWS infrastructure templates. `sam build` compiles and packages functions, including zip and container image Lambdas with custom Makefile workflows. `sam local` runs Lambdas and API Gateway behaviors in Docker on your machine for SAM and CDK apps.
`sam sync` pushes iterative changes to a developer account in the cloud, and `sam deploy` applies templates to AWS. `sam pipeline init` helps generate CI/CD pipeline skeletons for common systems. `sam logs` and `sam traces` tail CloudWatch logs and X-Ray traces from the terminal.
SAM templates are a shorthand for infrastructure as code that deploy through CloudFormation. The CLI also integrates with CDK and Terraform workflows for local debugging described in AWS documentation, so one tool can sit in a broader serverless toolchain.
Key features
- Project scaffolding with sam init
- Build and package Lambda artifacts
- Local Lambda and API in Docker
- Deploy SAM and CloudFormation stacks
- sam sync for cloud iteration
- CI/CD pipeline template generation
- CloudWatch log and X-Ray tailing
- CDK and Terraform local testing hooks
Use cases
- Building serverless web APIs
- Local Lambda debugging before deploy
- Rapid cloud sync during development
- Automated serverless delivery pipelines
- Hello-world to production SAM apps