Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
SAM + FastAPI + Mangum でお手軽サーバーレス
Search
abimaru
June 09, 2025
Technology
440
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
SAM + FastAPI + Mangum でお手軽サーバーレス
SAM + FastAPI + Mangum でお手軽サーバーレス
Strands Agents SDKをFastAPIに統合して、動くか試してみました。
abimaru
June 09, 2025
More Decks by abimaru
See All by abimaru
モノレポ × DevContainere 設計パターン
kugimiya
1
400
Other Decks in Technology
See All in Technology
[2026-09-11]SREは誰のもの?運用エンジニアが始める 「SRE領域への越境」とチームの進化の軌跡 〜Road to NEXT CRE
tosite
0
260
Genieを崇めよ
kameitomohiro
0
130
Issue 駆動でスペシャリストの意図を届ける、AI 実装のアクセシビリティ向上
thkt
0
110
Screen Lens - 今見てる画面を翻訳する
komagata
0
310
MCPをつなげて作る組織横断のAIエージェント基盤(の開発工程)
tsubakimoto_s
0
130
HHKBエバンジェリストになる方法
941
0
110
20260912_スクフェス三河
kgnkhkr
0
380
データ界隈LT祭 第1回LT登壇
taromatsui_cccmkhd
1
1.4k
株式会社シーエーシー エンジニア向け会社紹介資料
cac
0
57k
アプリログインとWeb認証基盤をつなぐ ASWebAuthenticationSession 作法
shimastripe
1
320
AIネイティブプロダクトで顧客価値を最大化するプロダクトエンジニアとFDEの協働
righttouch
PRO
0
310
2026-09-11 【Snowflake World Tour Tokyo 2026】Snowflakeを起点に、AI Agentが自律稼働し続ける未来へ / Driving AI Agents with Snowflake
civitaspo
0
530
Featured
See All Featured
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
63
46k
4 Signs Your Business is Dying
shpigford
187
23k
The SEO identity crisis: Don't let AI make you average
varn
0
560
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
910
How to train your dragon (web standard)
notwaldorf
97
6.8k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
280
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
540
Building an army of robots
kneath
307
46k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
2
430
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
5
650
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Darren the Foodie - Storyboard
khoart
PRO
4
3.9k
Transcript
SAM + FastAPI + Mangum で お手軽サーバーレス Strands Agents SDK
使ってみた 2025/06/07 JAWS-UG OITA 発表 @あびまる(釘宮) JAWS-UG 発表資料
自己紹介 名前: あびまる(釘宮) 所属: 株式会社スリーシェイク 経験言語: TypeScript, Golang, Python, Kotlin
環境: AWS, Google Cloud etc… GitHub: https://github.com/daikugimiya0715 JAWS-UG 発表資料 2
今日話すこと SAM + FastAPI + Mangumを使ったサーバーレスAPI開発について説明します。 その後に、Strands Agent SDKを統合した物のデモをします。 1.
なぜ SAM + FastAPI + Mangum なのか 2. 実装のポイント 3. コスト効率とスケーラビリティ 4. OpenAPI と Swagger の活用 5. 生成 AI 時代の Python 活用 6. デモ: Strands SDK 統合 JAWS-UG 発表資料 3
課題: API 開発の悩み 開発環境のセットアップが面倒 インフラコストが心配 スケーラビリティの考慮 ドキュメント生成の手間 生成 AI SDK
との統合 JAWS-UG 発表資料 4
解決策: SAM + FastAPI + Mangum 3 つの技術を組み合わせた現代的なアプローチ SAM: Infrastructure
as Code でインフラ管理 FastAPI: 高速で直感的な API 開発 Mangum: サーバーレス環境での ASGI 実行 メリット 開発効率: 型安全で高速な開発 コスト効率: 使った分だけの課金 運用効率: サーバー管理不要 + JAWS-UG 発表資料 5
SAM (Serverless Application Model) AWS 公式のサーバーレス開発フレームワーク Infrastructure as Code: YAML
でインフラ定義 ローカル開発: sam local start-api で即座にテスト 簡単デプロイ: sam build && sam deploy SAM の強み CloudFormation 拡張: AWS リソースを簡潔に定義 依存関係管理: 自動的にパッケージングとデプロイ 実際のメリット 学習コスト低: CloudFormation より簡単 デバッグ効率: ローカルで API をテスト可能 JAWS-UG 発表資料 6
FastAPI + Mangum FastAPI の特徴 自動 OpenAPI 生成: /docs で即座に
API 仕様確認 型安全: Python の型ヒントでバグ防止 高パフォーマンス: 非同期処理対応 Mangum の役割 ASGI ブリッジ: FastAPI を Lambda で実行 Zero Configuration: 設定不要で動作 ECS 移行対応: 同じコードでコンテナ化可能 JAWS-UG 発表資料 7
実装例 from fastapi import FastAPI from mangum import Mangum from
pydantic import BaseModel app = FastAPI(title="サーバーレス API") class Item(BaseModel): name: str price: int @app.post("/items/") async def create_item(item: Item): return {"item": item, "status": "created"} # Lambda用ハンドラー handler = Mangum(app) JAWS-UG 発表資料 8
なぜサーバーレスなのか? コスト面のメリット アイドル時コストゼロ: 使用していない時は課金なし 従量課金: リクエスト数に応じた課金 予算管理: 使用量に応じた透明な課金 運用面のメリット サーバー管理不要:
インフラ運用から解放 自動スケーリング: トラフィック増加に自動対応 ECS 移行: コード変更なしで可能 ← これが本当に嬉しい 実際の開発環境では月額数百円程度で運用可能! JAWS-UG 発表資料 9
なぜ Python なのか? 豊富な AI/ML 系 SDK OpenAI, Anthropic, AWS
Bedrock Langchain, LlamaIndex etc… データサイエンスエコシステム # 最新のAI SDKが揃っている import openai import anthropic import boto3 # Bedrock from strands import Agent # 今回のデモ JAWS-UG 発表資料 10
ついでに Strands SDK 使ってみる 実装例 from strands import Agent from
strands.models import BedrockModel # Bedrock Claude を使用 bedrock_model = BedrockModel( model_id="claude-3-sonnet", region_name="ap-northeast-1" ) agent = Agent( model=bedrock_model, tools=[calculator, shell, use_aws] ) @app.post("/chat") async def chat_with_agent(message: str): response = await agent.stream_async(message) return StreamingResponse(response) JAWS-UG 発表資料 11
実際のディレクトリ構成 fast-api-sam/ ├── app/ │ ├── __init__.py │ └── main.py
# FastAPI アプリ ├── template.yaml # SAM テンプレート ├── samconfig.toml # SAM 設定 ├── pyproject.toml # Python 依存関係 └── tests/ └── test_main.py # テスト JAWS-UG 発表資料 12
実際に動かしてみた結果 invoke エンドポイントの実行例 確認できたこと API が正常に動作: エンドポイントが期待通りにレスポンス S3 バケット情報取得: agent
のツールコール (use_aws) Stream レスポンス: Agent を使った Stream レスポンスの実装 JAWS-UG 発表資料 13
実際の運用メリット 開発体験 ローカル開発が快適 型安全性 自動ドキュメント生成 豊富なエコシステム 運用面 コスト効率 自動スケーリング メンテナンス不要
AWS 統合 JAWS-UG 発表資料 14
まとめ SAM + FastAPI + Mangum の価値 POCから本格運用まで一気通貫で対応できる、モダンなサーバーレスAPI開発スタッ クです。 1.
開発効率: 現代的な API 開発体験 2. コスト効率: 使った分だけの従量課金 3. 拡張性: ECS への移行も容易 4. AI 統合: Python 生態系の恩恵 5. ドキュメント: 自動生成で保守コスト削減 JAWS-UG 発表資料 15
質疑応答 ご質問をお待ちしています! GitHub: https://github.com/daikugimiya0715 X: https://x.com/abimaruXD ありがとうございました! JAWS-UG 発表資料 16
補足: 参考リンク AWS SAM FastAPI Mangum Strands SDK JAWS-UG 発表資料
17