Auto-sync: 2026-04-20 00:02

This commit is contained in:
2026-04-20 00:02:56 +08:00
parent 8341ee6cc4
commit 6ab2838935
104 changed files with 4077 additions and 31 deletions

View File

@@ -0,0 +1,51 @@
---
title: "Serverless Application Model"
type: concept
tags:
- AWS
- Serverless
- IaC
- SAM
date: 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
```yaml
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