← Back to all products
$39
Serverless Patterns Collection
30+ serverless architecture patterns with Lambda/Functions implementations, event-driven designs, and cost optimization.
JSONPythonYAMLMarkdownTerraformAWSCI/CD
📄 Product Preview
Try the interactive reader and demo tools below, or get the full product with all content unlocked.
📖 Interactive Reader (Free Preview) ⚙ Try Demo Tools 📦 Download Free Sample📁 File Structure 27 files
serverless-patterns-collection/
├── LICENSE
├── README.md
├── cloudformation/
│ ├── api-gateway-lambda.yaml
│ ├── cqrs-event-sourcing.yaml
│ ├── event-driven-pipeline.yaml
│ ├── fan-out-pattern.yaml
│ └── saga-orchestration.yaml
├── docs/
│ ├── architecture.md
│ ├── cost-optimization.md
│ ├── deployment-guide.md
│ ├── patterns-catalog.md
│ └── security-considerations.md
├── examples/
│ ├── api-gateway-config.json
│ ├── event-bridge-rules.json
│ └── step-functions-definition.json
├── free-sample.zip
├── functions/
│ ├── api_handler.py
│ ├── event_processor.py
│ ├── saga_coordinator.py
│ └── stream_processor.py
├── guide/
│ ├── 01_what-s-included.md
│ ├── 02_architecture-overview.md
│ ├── 03_cost-estimates.md
│ └── 04_license.md
├── index.html
└── scripts/
├── cost_calculator.py
└── pattern_selector.py
📖 Documentation Preview README excerpt
Serverless Patterns Collection
Production-ready AWS serverless architecture patterns with CloudFormation templates, Lambda implementations, and comprehensive documentation.
A curated collection of 5 core serverless patterns (with 30+ pattern variations documented) that solve the most common distributed systems challenges on AWS. Each pattern includes deployable infrastructure-as-code, working Lambda functions, and deep-dive documentation on architecture decisions, cost optimization, and security.
What's Included
CloudFormation Templates (5)
| Template | Pattern | Description |
|---|---|---|
api-gateway-lambda.yaml | Synchronous REST API | API Gateway + Lambda + DynamoDB with throttling, alarms, and X-Ray |
event-driven-pipeline.yaml | Event-Driven Pipeline | EventBridge + SQS + Lambda with DLQ and event archival |
fan-out-pattern.yaml | Fan-Out (One-to-Many) | SNS + 3 SQS consumers with filter policies and dashboards |
saga-orchestration.yaml | Saga Orchestration | Step Functions + 7 Lambda functions with compensation chain |
cqrs-event-sourcing.yaml | CQRS + Event Sourcing | DynamoDB Streams + Lambda projector + separate read/write models |
Lambda Functions (4)
| Function | Purpose | Lines |
|---|---|---|
api_handler.py | REST API CRUD handler with validation, routing, correlation IDs | ~400 |
event_processor.py | SQS batch processor with idempotency, partial failure reporting | ~300 |
saga_coordinator.py | Step Functions task handlers (4 steps + 3 compensations) | ~350 |
stream_processor.py | DynamoDB Streams projector for CQRS read model | ~350 |
Documentation (5)
| Document | Content |
|---|---|
docs/architecture.md | Reference architecture with Mermaid diagrams, cost model, deployment strategy |
docs/patterns-catalog.md | 36 serverless patterns organized by category with trade-offs |
docs/cost-optimization.md | Lambda right-sizing, DynamoDB optimization, API Gateway savings |
docs/security-considerations.md | OWASP Serverless Top 10, IAM best practices, security checklist |
docs/deployment-guide.md | Step-by-step deployment, CI/CD integration, troubleshooting |
Scripts (2)
| Script | Purpose |
|---|---|
scripts/pattern_selector.py | Interactive tool to find the right pattern for your use case |
scripts/cost_calculator.py | Estimate monthly costs for each pattern at any traffic level |
Examples (3)
| Example | Content |
|---|---|
examples/api-gateway-config.json | API Gateway stage configuration with throttling per method |
examples/event-bridge-rules.json | EventBridge rule patterns with content-based filtering examples |
examples/step-functions-definition.json | Extended Step Functions state machine with parallel branches |
Quick Start
1. Choose Your Pattern
# Run the interactive pattern selector
python3 scripts/pattern_selector.py
*... continues with setup instructions, usage examples, and more.*
📄 Code Sample .py preview
scripts/cost_calculator.py#!/usr/bin/env python3
"""
Serverless Cost Calculator — Estimate AWS Serverless Costs
Calculates estimated monthly costs for AWS serverless architectures
based on expected traffic patterns, function configurations, and
data storage requirements.
Usage:
python3 cost_calculator.py # Interactive mode
python3 cost_calculator.py --requests 1000000 # Quick estimate
python3 cost_calculator.py --json # JSON output
python3 cost_calculator.py --compare # Compare patterns
This script uses only Python stdlib — no external dependencies required.
"""
from __future__ import annotations
import argparse
import json
import sys
from dataclasses import dataclass, field
from typing import Any
# ─── AWS Pricing Constants (us-east-1, as of 2025) ───────────
# These are approximate prices. Actual prices may vary by region
# and are subject to change. Always verify with the AWS Pricing page.
@dataclass(frozen=True)
class AWSPricing:
"""AWS service pricing constants (us-east-1)."""
# Lambda pricing
lambda_request_cost: float = 0.0000002 # per request
lambda_duration_cost_x86: float = 0.0000166667 # per GB-second (x86)
lambda_duration_cost_arm: float = 0.0000133334 # per GB-second (ARM, 20% cheaper)
lambda_free_requests: int = 1_000_000 # per month
lambda_free_duration_gb_s: float = 400_000.0 # per month