MCPcopy Index your code
hub / github.com/cdk-patterns/serverless

github.com/cdk-patterns/serverless @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
395 symbols 1,003 edges 435 files 2 documented · 1%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

This is intended to be a repo containing all of the official AWS Serverless architecture patterns built with AWS CDK for developers to use.

Follow @CdkPatterns for live discussion / new pattern announcements. I plan to add a new pattern weekly so check back regularly!

You can also check out our Deconstructing CDKPatterns YouTube channel for in depth walk throughs of the patterns.

Note, this is maintained by @nideveloper not AWS. For my motivation, please read this blog post

New to AWS CDK?

Pattern Usage

All patterns are available in Typescript and Python so pick your favourite language! Note the Typescript patterns all include unit tests but right now I have not seen a standard python testing approach

You can always clone this repo which contains every pattern in python/typescript but if you just want a single pattern in one language follow these steps:

1) Choose your pattern

Browse the "Grouped Alphabetically" patterns list below or run:

npx cdkp list

2) Download Pattern In Python or Typescript CDK

Something to be aware of is that the Python version may reuse the JS lambdas from the TypeScript version. This is to reduce the amount of development effort when creating these patterns. It means at launch the TypeScript and Python patterns are effectively identical when deployed but you get the choice of Python or TypeScript for the CDK implementation.

I will look to refactor the Python patterns slowly to full Python after initial launch. If you want to help with this effort, pull requests are always welcome!

TypeScript

All Patterns support the same commands so you can just run:

```bash npx cdkp init {pattern-name} cd {pattern-name} npm run test

requires you to be using cloud9 or have ran aws configure to setup your local credentials

npm run deploy









Python





  The CDK CLI is still installed via npm so make sure you have the latest version of node installed or the npx commands will fail. Then you can just run:




  ```bash
npx cdkp init {pattern-name} --lang=python
cd {pattern-name}

# create a virtual env and install your dependencies
python -m venv .env
source .env/bin/activate
pip install -r requirements.txt

# test everything is working by outputting the cloudformation
npx cdk synth
# requires you to be using cloud9 or have ran aws configure to setup your local credentials
npx cdk deploy

Patterns

The Filter Pattern By Component Used Page allows you to filter patterns by a serverless component e.g. Lambda or API Gateway HTTP API visit, otherwise:

Grouped Alphabetically

#### Polly Use Amazon Polly to translate text to speech from inside a Lambda Function. You can also take advantage of Amazon Translate to change the language of the spoken text

Architecture


#### Single Page Application S3 Website Deploy These are built using https://www.npmjs.com/package/cdk-spa-deploy and allow you to deploy a website in as little as 5 lines of CDK code.

Architecture


#### The Alexa Skill
Deploy an Alexa Skill backed by a Lambda Function and a DynamoDB Table.

Architecture


#### The Basic MQ
In this example we have private Amazon MQ brokers behind an internet-facing network load balancer endpoint using a subdomain.

Architecture


#### The Big Fan
You can integrate API Gateway directly with SNS and then add some resiliency by integrating your event consumers via sqs and message filtering.

Architecture


#### The CloudWatch Dashboard
Build and deploy a well architected CloudWatch dashboard with alerts for the simple webservice pattern

Architecture


#### The Destined Lambda This is a stock implementation of Lambda Destinations with Amazon EventBridge

You can decouple your event driven architectures with EventBridge rules and now you can strip the custom EventBridge code from your Lambda functions with Lambda Destinations.

Architecture


#### The Dynamo Streamer This was taken from this Tweet

You can integrate API Gateway directly with DynamoDB and that way your systems can be more resilient! "Code is a liability" so less lambda functions, less liability

Architecture


#### The EFS Lambda This was taken from this Blogpost

You can now attach an EFS File System to your Lambda Function for persistence between executions or across different Functions

Architecture


#### The EventBridge ATM This was taken from this Blogpost

You can easily create routing rules in EventBridge to send the same event to multiple sources based on conditions. This example shows you how

Architecture


#### The EventBridge Circuit Breaker Integrate with unreliable external services? Build a circuit breaker and handle the risk

Architecture


#### The EventBridge ETL Build a fully serverless CSV to DynamoDB pipeline

Architecture


#### The Lambda Circuit Breaker Deploy Gunnar Grosch's circuitbreaker-lambda inside a reference architecture

Architecture


#### The Lambda Power Tuner Use the Lambda Power Tuner state machine to work out the optimum configuration settings for your Lambda Function

Architecture


#### The Lambda Trilogy See the 3 states of Lambda in action (Single Purpose Function, Fat Lambda and Lambda-lith) Architecture


#### The Media Live Stream This is an example of how to deploy a Serverless environment to stream live event content. Architecture


#### The Predictive Lambda Deploy a custom Python ML model inside a Docker container running on AWS Lambda Architecture


#### The RDS Proxy Use RDS Proxy to protect a MySQL RDS Instance from the massively scalable Lambda Function querying it Architecture


#### The Saga Step Function A mechanism for handling distributed transactions within your system. Architecture


#### The Scalable Webhook Need to integrate a non serverless resource like RDS with a serverless one like Lambda? This is your pattern

Architecture


#### The Scheduled Lambda Use EventBridge to trigger a Lambda Fuction on a schedule

Architecture


#### The Simple GraphQL Service Simple graphQL service built with AppSync

Architecture


#### The Simple Webservice The most basic pattern on cdkpatterns, the start of most peoples serverless journey

Architecture


#### The State Machine Have complex orchestration logic in your application? Build a state machine

Architecture


#### The WAF API Gateway This is a cdk stack to deploy a simple API gateway, and attach a WAF (Web Application Firewall)

Architecture


#### The X-Ray Tracer Learn about using AWS X-Ray for tracing events through your system. This pattern has X-Ray enabled on API Gateway, Lambda, DynamoDB, External HTTP calls, SNS and SQS

Architecture


Grouped By Pattern Creator

### Alex Casalboni Alex Casalboni profile pic

Musician, Traveler, Software Engineer from Italy. Developer Advocate at @AWS_Italy

Twitter - @alex_casalboni

#### The Lambda Power Tuner Use the Lambda Power Tuner state machine to work out the optimum configuration settings for your Lambda Function

Architecture


### Andrew Frazer Andrew Frazer profile pic

Github - @mrpackethead

#### The WAF API Gateway This is a cdk stack to deploy a simple API gateway, and attach a WAF (Web Application Firewall)

Architecture


### Ariadna Sanchez Ariadna Sanchez profile pic

Ariadna Sanchez is a Research Scientist investigating the application of DL/ML technologies in the area of text-to-speech. After completing a bachelor’s in Audiovisual Systems Engineering, she received her MSc in Speech and Language Processing from University of Edinburgh in 2018. She has previously worked as an intern in NLP and TTS. During her time at University, she focused on TTS and signal processing, especially in the dysarthria field. She has experience in Signal Processing, Deep Learning, NLP, Speech and Image Processing. In her free time, Ariadna likes playing the violin, reading books and playing games.

#### Polly
Use Amazon Polly to translate text to speech from inside a Lambda Function. You can also take advantage of Amazon Translate to change the language of the spoken text

Architecture


### Chris Plankey Chris Plankey profile pic

CTO of MaverickApp.io, AWS Portsmouth User Group Co-Organizer and AWS Com

Extension points exported contracts — how you extend this code

WafStackProps (Interface)
(no doc)
the-waf-apigateway/typescript/lib/the-waf-stack.ts
DynamoFlowStackProps (Interface)
(no doc)
the-xray-tracer/typescript/lib/the-dynamo-flow-stack.ts
HttpFlowStackProps (Interface)
(no doc)
the-xray-tracer/typescript/lib/the-http-flow-stack.ts
SNSFlowStackProps (Interface)
(no doc)
the-xray-tracer/typescript/lib/the-sns-flow-stack.ts
SQSFlowStackProps (Interface)
(no doc)
the-xray-tracer/typescript/lib/the-sqs-flow-stack.ts

Core symbols most depended-on inside this repo

metric_for_api_gw
called by 10
the-cloudwatch-dashboard/python/the_cloudwatch_dashboard/the_cloudwatch_dashboard_stack.py
metricForApiGw
called by 10
the-cloudwatch-dashboard/typescript/lib/the-cloudwatch-dashboard-stack.ts
buildGraphWidget
called by 9
the-cloudwatch-dashboard/typescript/lib/the-cloudwatch-dashboard-stack.ts
create_lambda
called by 8
the-saga-stepfunction/python/the_saga_stepfunction/the_saga_stepfunction_stack.py
createLambda
called by 8
the-saga-stepfunction/typescript/lib/the-saga-stepfunction-single-table-stack.ts
step
called by 4
the-lambda-circuit-breaker/python/lambda_fns/unreliable.js
step
called by 4
the-alexa-skill/python/lambda_fns/lambda.js
verb
called by 3
the-lambda-circuit-breaker/python/lambda_fns/unreliable.js

Shape

Class 150
Method 119
Function 118
Interface 5
Route 3

Languages

TypeScript51%
Python31%
Java9%
C#8%

Modules by API surface

the-lambda-trilogy/python/lambda_fns/the_lambda_lith/flask/lambdalith.py7 symbols
the-lambda-circuit-breaker/python/lambda_fns/unreliable.js7 symbols
the-alexa-skill/python/lambda_fns/lambda.js7 symbols
the-cloudwatch-dashboard/typescript/lib/the-cloudwatch-dashboard-stack.ts6 symbols
the-simple-webservice/java/cdk/src/main/java/com/cdkpatterns/TheSimpleWebserviceStack.java5 symbols
the-xray-tracer/typescript/lib/the-sqs-flow-stack.ts4 symbols
the-xray-tracer/typescript/lib/the-sns-flow-stack.ts4 symbols
the-xray-tracer/typescript/lib/the-http-flow-stack.ts4 symbols
the-xray-tracer/typescript/lib/the-dynamo-flow-stack.ts4 symbols
the-waf-apigateway/typescript/lib/the-waf-stack.ts4 symbols
the-simple-webservice/java/lambda/src/main/java/com/cdkpatterns/LambdaHandler.java4 symbols
the-saga-stepfunction/typescript/lib/the-saga-stepfunction-single-table-stack.ts4 symbols

For agents

$ claude mcp add serverless \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact