Concepts

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

AspectSAMCDK
FormatYAML (declarative)TypeScript/Python (imperative)
Learning curveLowerHigher
Local developmentsam local built-inRequires additional tools
FlexibilityServerless-focusedAny AWS resource

Notable CLI commands

  • sam init: project scaffolding
  • sam build: compile functions
  • sam local invoke: run Lambda locally
  • sam local start-api: local API Gateway
  • sam deploy: deploy to AWS
  • sam 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: get

Why 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

Concepts