AWS SAM
AWS open-source framework for building serverless applications with simplified CloudFormation syntax, CLI for local development, and integrated deployment.
seed#aws#sam#serverless#cloudformation#cli#local-development
What it is
AWS SAM (Serverless Application Model) is a framework that simplifies defining and deploying serverless applications. It extends CloudFormation with high-level resources (AWS::Serverless::Function, AWS::Serverless::Api) and provides a CLI for local development.
SAM vs CDK
| Aspect | SAM | CDK |
|---|---|---|
| Format | YAML (declarative) | TypeScript/Python (imperative) |
| Learning curve | Lower | Higher |
| Local development | sam local built-in | Requires additional tools |
| Flexibility | Serverless-focused | Any AWS resource |
Notable CLI commands
sam init: project scaffoldingsam build: compile functionssam local invoke: run Lambda locallysam local start-api: local API Gatewaysam deploy: deploy to AWSsam sync: fast sync during development
Example template.yaml
Resources:
HelloFunction:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: nodejs20.x
Events:
Api:
Type: Api
Properties:
Path: /hello
Method: getWhy it matters
SAM simplifies serverless development by providing a concise syntax on top of CloudFormation and local development tools. For teams building APIs with Lambda and API Gateway, SAM reduces boilerplate and enables testing functions locally before deploying.
References
- SAM Documentation — Official documentation.
- SAM CLI Reference — AWS, 2024. CLI command reference.
- AWS SAM — AWS, 2024. Official product page.