Files
nexus/wiki/concepts/Serverless-Application-Model.md
2026-04-20 00:02:56 +08:00

1.2 KiB
Raw Blame History

title, type, tags, date
title type tags date
Serverless Application Model concept
AWS
Serverless
IaC
SAM
2024-09-03

Definition

Serverless Application Model无服务器应用模型SAM是 AWS 提供的开源框架,用于简化无服务器应用的本地开发和部署。基于 CloudFormation扩展了声明无服务器资源的简化的语法。

Key Features

  • SAM CLI
    • sam init:初始化项目
    • sam build:本地构建
    • sam local:本地运行和调试
    • sam deploy:部署到 AWS
  • 模板简化:相比 CloudFormation 更简洁的语法
  • 本地测试:支持本地调用 Lambda 和 Step Functions

SAM Template Structure

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-08-09
Resources:
  MyFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: index.handler
      Runtime: nodejs18.x
      Events:
        Api:
          Type: Api
          Properties:
            Path: /hello
            Method: get

Common Use Cases

  • Lambda 函数部署
  • API Gateway 集成
  • Step Functions 工作流
  • 事件驱动架构

Aliases

  • AWS SAM
  • SAM
  • Serverless Application Model