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

51 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
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