← Back to all products

Serverless Patterns Collection

$39

30+ serverless architecture patterns with Lambda/Functions implementations, event-driven designs, and cost optimization.

📁 27 files
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)

TemplatePatternDescription
api-gateway-lambda.yamlSynchronous REST APIAPI Gateway + Lambda + DynamoDB with throttling, alarms, and X-Ray
event-driven-pipeline.yamlEvent-Driven PipelineEventBridge + SQS + Lambda with DLQ and event archival
fan-out-pattern.yamlFan-Out (One-to-Many)SNS + 3 SQS consumers with filter policies and dashboards
saga-orchestration.yamlSaga OrchestrationStep Functions + 7 Lambda functions with compensation chain
cqrs-event-sourcing.yamlCQRS + Event SourcingDynamoDB Streams + Lambda projector + separate read/write models

Lambda Functions (4)

FunctionPurposeLines
api_handler.pyREST API CRUD handler with validation, routing, correlation IDs~400
event_processor.pySQS batch processor with idempotency, partial failure reporting~300
saga_coordinator.pyStep Functions task handlers (4 steps + 3 compensations)~350
stream_processor.pyDynamoDB Streams projector for CQRS read model~350

Documentation (5)

DocumentContent
docs/architecture.mdReference architecture with Mermaid diagrams, cost model, deployment strategy
docs/patterns-catalog.md36 serverless patterns organized by category with trade-offs
docs/cost-optimization.mdLambda right-sizing, DynamoDB optimization, API Gateway savings
docs/security-considerations.mdOWASP Serverless Top 10, IAM best practices, security checklist
docs/deployment-guide.mdStep-by-step deployment, CI/CD integration, troubleshooting

Scripts (2)

ScriptPurpose
scripts/pattern_selector.pyInteractive tool to find the right pattern for your use case
scripts/cost_calculator.pyEstimate monthly costs for each pattern at any traffic level

Examples (3)

ExampleContent
examples/api-gateway-config.jsonAPI Gateway stage configuration with throttling per method
examples/event-bridge-rules.jsonEventBridge rule patterns with content-based filtering examples
examples/step-functions-definition.jsonExtended 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

functions/api_handler.py """ Serverless REST API Handler — Lambda Function for API Gateway Integration This module implements a production-ready Lambda handler for REST API operations. It demonstrates best practices for: - Structured logging with correlation IDs for distributed tracing - Input validation with descriptive error messages - DynamoDB single-table design with composite keys - Proper HTTP response formatting for API Gateway proxy integration - Idempotency for safe retries - Cold start optimization techniques Architecture: API Gateway (REST) -> Lambda (this handler) -> DynamoDB Usage: Deploy with the api-gateway-lambda.yaml CloudFormation template. The handler entry point is `handler(event, context)`. Environment Variables: TABLE_NAME: DynamoDB table name (set by CloudFormation) ENVIRONMENT: Deployment environment (dev/staging/prod) LOG_LEVEL: Logging level (DEBUG/INFO/WARNING/ERROR) """ from __future__ import annotations import json import logging import os import time import uuid from datetime import datetime, timezone from typing import Any # ─── Configuration ──────────────────────────────────────────── # Read configuration from environment variables set by CloudFormation. # Using os.environ.get() with defaults makes local testing easier. TABLE_NAME = os.environ.get("TABLE_NAME", "local-dev-table") ENVIRONMENT = os.environ.get("ENVIRONMENT", "dev") LOG_LEVEL = os.environ.get("LOG_LEVEL", "INFO") # ─── Logging Setup ──────────────────────────────────────────── # Configure structured logging. In production, use JSON format # so CloudWatch Insights can parse and query log fields. logger = logging.getLogger(__name__) logger.setLevel(getattr(logging, LOG_LEVEL, logging.INFO)) def _json_serial(obj: Any) -> str: # ... 517 more lines ...
Buy Now — $39 Back to Products