CARVIEW |
What is the AWS Serverless Application Model (AWS SAM)?
AWS Serverless Application Model (AWS SAM) is an open-source framework for building serverless applications using infrastructure as code (IaC).
With AWS SAM’s shorthand syntax, developers declare AWS CloudFormation
When to use AWS SAM
AWS SAM is an ideal IaC solution for scenarios where you want simplified serverless development with the full power of AWS CloudFormation. For example, you can use SAM for:
-
Serverless applications: You can use SAM to quickly define AWS Lambda functions, Amazon API Gateway APIs, Amazon DynamoDB tables, and other serverless resources with minimal code.
-
AWS CloudFormation enhancement: You can combine SAM with existing CloudFormation templates to add serverless components to traditional infrastructure. SAM resources work alongside standard CloudFormation resources in the same template.
-
Local development and testing: You can use the SAM CLI to test Lambda functions locally, simulate API Gateway endpoints, and debug serverless applications on your development machine before deploying to AWS.
-
CI/CD for serverless: You can build deployment pipelines using SAM templates that automatically generate the CloudFormation infrastructure needed for staging and production environments.
-
Migration from console-created resources: You can convert Lambda functions and API Gateway resources created in the AWS Management Console into infrastructure as code using SAM templates.
Comparing AWS SAM with other IaC tools
-
Use SAM instead of CloudFormation to simplify serverless resource definitions while maintaining template compatibility.
-
Use SAM instead of AWS CDK if you prefer a declarative approach to describing your infrastructure rather than a programmatic one.
-
Combine SAM with AWS CDK by using SAM CLI's local testing features to enhance your CDK applications.
Key features
AWS SAM offers a variety of benefits that improve the developer experience by allowing you to:
- Define your application infrastructure code quickly, using less code
-
Author AWS SAM templates to define your serverless application infrastructure code. Deploy your templates directly to AWS CloudFormation to provision your resources.
- Manage your serverless applications through their entire development lifecycle
-
Use the AWS SAM CLI to manage your serverless application through the authoring, building, deploying, testing, and monitoring phases of your development lifecycle. For more information, see The AWS SAM CLI.
- Quickly provision permissions between resources with AWS SAM connectors
-
Use AWS SAM connectors in your AWS SAM templates to define permissions between your AWS resources. AWS SAM transforms your code into the IAM permissions required to facilitate your intent. For more information, see Managing resource permissions with AWS SAM connectors.
- Continuously sync local changes to the cloud as you develop
-
Use the AWS SAM CLI sam sync command to automatically sync local changes to the cloud, speeding up your development and cloud testing workflows. For more information, see Introduction to using sam sync to sync to AWS Cloud.
- Manage your Terraform serverless applications
-
Use the AWS SAM CLI to perform local debugging and testing of your Lambda functions and layers. For more information, see AWS SAM CLI Terraform support.
Related information
For information on how AWS SAM works, see How AWS SAM works.
To start using AWS SAM, see Getting started with AWS SAM.
For an overview on how you can use AWS SAM to create a serverless application, see How to use AWS SAM.
Thanks for letting us know we're doing a good job!
If you've got a moment, please tell us what we did right so we can do more of it.
Thanks for letting us know this page needs work. We're sorry we let you down.
If you've got a moment, please tell us how we can make the documentation better.