AWS Serverless Application Model (AWS SAM)
The AWS Serverless Application Model (SAM) is an open-source framework for building serverless applications. It provides shorthand syntax to express functions, APIs, databases, and event source mappings. With just a few lines of configuration, you can define the application you want and model it.
Get Started
To get started with building SAM-based applications, use the SAM CLI. SAM CLI provides a Lambda-like execution environment that lets you locally build, test, debug, and deploy applications defined by SAM templates.
- Install SAM CLI
- Build & Deploy a "Hello World" Web App
- Install AWS Toolkit to use SAM with your favorite IDEs.
Next Steps: Learn to build a more complex serverless application.
- Extract text from images and store in a database using Amazon S3 and Amazon Rekognition services.
- Detect when records are added to a database using Amazon DynamoDB database and asynchronous stream processing.
Detailed References: Explains SAM commands and usage in depth.
Why SAM
-
Single-deployment configuration. SAM makes it easy to organize related components and resources, and operate on a single stack. You can use SAM to share configuration (such as memory and timeouts) between resources, and deploy all related resources together as a single, versioned entity.
-
Local debugging and testing. Use SAM CLI to locally build, test, and debug SAM applications on a Lambda-like execution environment. It tightens the development loop by helping you find & troubleshoot issues locally that you might otherwise identify only after deploying to the cloud.
-
Deep integration with development tools. You can use SAM with a suite of tools you love and use.
- IDEs: PyCharm, IntelliJ, Visual Studio Code, Visual Studio, AWS Cloud9
- Build: CodeBuild
- Deploy: CodeDeploy, Jenkins
- Continuous Delivery Pipelines: CodePipeline
- Discover Serverless Apps & Patterns: AWS Serverless Application Repository
-
Built-in best practices. You can use SAM to define and deploy your infrastructure as configuration. This makes it possible for you to use and enforce best practices through code reviews. Also, with a few lines of configuration, you can enable safe deployments through CodeDeploy, and can enable tracing using AWS X-Ray.
-
Extension of AWS CloudFormation. Because SAM is an extension of AWS CloudFormation, you get the reliable deployment capabilities of AWS CloudFormation. You can define resources by using CloudFormation in your SAM template. Also, you can use the full suite of resources, intrinsic functions, and other template features that are available in CloudFormation.
What is this Github repository? 💻
This GitHub repository contains the SAM Specification, the Python code that translates SAM templates into AWS CloudFormation stacks and lots of examples applications. In the words of SAM developers:
SAM Translator is the Python code that deploys SAM templates via AWS CloudFormation. Source code is high quality (95% unit test coverage), with tons of tests to ensure your changes don't break compatibility. Change the code, run the tests, and if they pass, you should be good to go! Clone it and run
make pr
!
Contribute to SAM
We love our contributors ❤️ We have over 100 contributors who have built various parts of the product. Read this testimonial from @ndobryanskyy to learn more about what it was like contributing to SAM.
Depending on your interest and skill, you can help build the different parts of the SAM project;
Enhance the SAM Specification
Make pull requests, report bugs, and share ideas to improve the full SAM template specification. Source code is located on Github at awslabs/serverless-application-model. Read the SAM Specification Contributing Guide to get started.
Strengthen SAM CLI
Add new commands or enhance existing ones, report bugs, or request new features for the SAM CLI. Source code is located on Github at awslabs/aws-sam-cli. Read the SAM CLI Contributing Guide to get started.
Update SAM Developer Guide
SAM Developer Guide provides comprehensive getting started guide and reference documentation. Source code is located on Github at awsdocs/aws-sam-developer-guide. Read the SAM Documentation Contribution Guide to get started.
Join the SAM Community on Slack
Join the SAM developers channel (#samdev) on Slack to collaborate with fellow community members and the AWS SAM team.