-
Notifications
You must be signed in to change notification settings - Fork 0
AWS ‐ SAM (Serverless Application Model)
Full Stack edited this page Mar 13, 2025
·
5 revisions
AWS Serverless Application Model (SAM) is an open-source framework designed to build, test, and deploy serverless applications on AWS. It extends AWS CloudFormation by providing shorthand syntax for defining Lambda functions, API Gateway, DynamoDB tables, and other serverless resources.
With AWS SAM, you can:
- Define serverless applications using a simplified YAML syntax.
- Build locally using the AWS SAM CLI (e.g., test Lambda, invoke APIs, debug).
- Deploy applications with built-in best practices.
- Use AWS SAM Accelerate for faster deployments.
Feature | AWS SAM | AWS CloudFormation |
---|---|---|
Purpose | Designed for serverless applications | Manages all AWS infrastructure |
Syntax | Simplified YAML with built-in serverless components | More verbose, requires manual setup for serverless |
Local Testing | Supports local testing/debugging using SAM CLI | No built-in local testing |
CLI Features | sam build, sam deploy, sam local invoke | Uses aws cloudformation deploy |
Transform | Uses AWS::Serverless-2016-10-31 transform to convert SAM templates into standard CloudFormation | No transformation required |
Deployment Speed | Faster for serverless apps using incremental changes | Slower due to full-stack deployments |
Extensibility | Can use CloudFormation resources inside a SAM template | Fully flexible for all AWS resources |
✅ Use AWS SAM when:
- Building serverless applications (Lambda, API Gateway, DynamoDB, Step Functions).
- Need local testing/debugging before deployment.
- Want a simplified YAML template for infrastructure.
- Need faster deployments with
sam accelerate
.
❌ Use CloudFormation when:
- Managing a full-stack AWS infrastructure (e.g., EC2, RDS, VPC, networking).
- Defining complex dependencies across AWS services.
- Working with hybrid architectures (serverless + traditional).
AWS SAM is CloudFormation for serverless applications with added benefits like local testing and simplified configuration. If you're building a serverless app, use SAM. If managing a broader AWS infrastructure, use CloudFormation.