This chapter covers the core features and capabilities of Serverless Patterns Collection.
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
# Run the interactive pattern selector
python3 scripts/pattern_selector.py
# Or see all patterns at a glance
python3 scripts/pattern_selector.py --all# Compare all patterns at 1M requests/month
python3 scripts/cost_calculator.py --requests 1000000
# Full comparison across traffic levels
python3 scripts/cost_calculator.py --compare# Package Lambda functions
cd functions/
zip -r ../lambda-package.zip *.py
aws s3 cp ../lambda-package.zip s3://your-bucket/lambda-package.zip
# Deploy the REST API pattern (example)
aws cloudformation deploy \
--template-file cloudformation/api-gateway-lambda.yaml \
--stack-name my-api-dev \
--parameter-overrides Environment=dev ApiName=my-api \
--capabilities CAPABILITY_NAMED_IAM
# Get the API URL
aws cloudformation describe-stacks \
--stack-name my-api-dev \
--query "Stacks[0].Outputs[?OutputKey=='ApiUrl'].OutputValue" \
--output textAll Lambda functions include if __name__ == "__main__": blocks for local testing:
# Test the API handler
python3 functions/api_handler.py
# Test the event processor
python3 functions/event_processor.py
# Test the saga coordinator
python3 functions/saga_coordinator.py
# Test the stream processor
python3 functions/stream_processor.py| Question | REST API | Event Pipeline | Fan-Out | Saga | CQRS |
|---|---|---|---|---|---|
| Need sync response? | Yes | No | No | Maybe | Partial |
| Latency requirement? | < 1s | 1-30s | 1-30s | Seconds | Read: low |
| Multiple consumers? | No | 1 | Multiple | No | Separate |
| Multi-step transaction? | No | No | No | Yes | No |
| Audit trail needed? | Maybe | Some | No | Yes | Yes |
| Team complexity budget? | Low | Medium | Medium | High | Very High |
Follow this guide to get Serverless Patterns Collection up and running in your environment.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β API Layer β
β ββββββββββββ ββββββββββββ ββββββββββββ β
β β REST API β β WebSocketβ β Scheduledβ β
β β (APIGW) β β (APIGW) β β (EventBr)β β
β ββββββ¬ββββββ ββββββ¬ββββββ ββββββ¬ββββββ β
βββββββββΌβββββββββββββββΌββββββββββββββΌββββββββββββββββββββββββββ€
β β Compute Layer β β
β ββββββ΄ββββββ ββββββ΄ββββββ ββββββ΄ββββββ β
β β Lambda β β Lambda β β Lambda β β
β β (Handler)β β(Processor)β β (Cron) β β
β ββββββ¬ββββββ ββββββ¬ββββββ ββββββ¬ββββββ β
βββββββββΌβββββββββββββββΌββββββββββββββΌββββββββββββββββββββββββββ€
β β Messaging Layer β β
β ββββββ΄ββββββ ββββββ΄ββββββ ββββββ΄ββββββ β
β βEventBridgβ β SQS β β SNS β β
β β (Bus) β β (Queues) β β (Topics) β β
β ββββββββββββ ββββββββββββ ββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Orchestration Layer β
β ββββββββββββββββββββββββββββββββββββββββββββ β
β β Step Functions (Sagas) β β
β ββββββββββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Storage Layer β
β ββββββββββββ ββββββββββββ ββββββββββββ β
β β DynamoDB β β DynamoDB β β S3 β β
β β (Tables) β β(Streams) β β (Objects)β β
β ββββββββββββ ββββββββββββ ββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
serverless-patterns-collection/
βββ README.md # This file
βββ LICENSE # MIT License
β
βββ cloudformation/ # Infrastructure-as-Code templates
β βββ api-gateway-lambda.yaml # Pattern 1: Synchronous REST API
β βββ event-driven-pipeline.yaml # Pattern 2: Event-Driven Pipeline
β βββ fan-out-pattern.yaml # Pattern 3: Fan-Out (One-to-Many)
β βββ saga-orchestration.yaml # Pattern 4: Saga Orchestration
β βββ cqrs-event-sourcing.yaml # Pattern 5: CQRS + Event Sourcing
β
βββ functions/ # Lambda function implementations
β βββ api_handler.py # REST API handler (CRUD + CQRS)
β βββ event_processor.py # SQS event processor (batch + DLQ)
β βββ saga_coordinator.py # Saga steps + compensations
β βββ stream_processor.py # DynamoDB Streams projector
β
βββ docs/ # Deep-dive documentation
β βββ architecture.md # Reference architecture + diagrams
β βββ patterns-catalog.md # 36 serverless patterns catalog
β βββ cost-optimization.md # Cost optimization strategies
β βββ security-considerations.md # Security best practices
β βββ deployment-guide.md # Deployment instructions
β
βββ scripts/ # Utility tools
β βββ pattern_selector.py # Interactive pattern selection tool
β βββ cost_calculator.py # Serverless cost estimator
β
βββ examples/ # Configuration examples
βββ api-gateway-config.json # API Gateway stage settings
βββ event-bridge-rules.json # EventBridge rule patterns
βββ step-functions-definition.json # Extended state machine example
Get the full Serverless Patterns Collection and unlock everything.
Get the complete guide with every chapter unlocked, including code samples, diagrams, and best practices.
Access all interactive tools with complete data, all workload profiles, and the full scenario library.
Downloadable source code, configuration files, and working examples from every chapter.
Free updates for life. Every new chapter, tool, and improvement included.