This project demonstrates how to use AWS CDK with Turborepo and DDD.
I want to answer the following questions by giving examples and resources:
- How to structure a CDK project
- How to apply DDD to a serverless architecture
- How to use Turborepo to manage a CDK project
- How to leverage certain sevices with the CDK
Each stack focuses on a specific AWS services and tries to show how to use it with the CDK.
The project is structured as follows:
iac/
- contains the CDK project and everything related to the backend infrastructurepackages/
- contains the domains that are deployed to the backend infrastructure
Services are structured in a very simplified DDD manner. This is inspired by a great introduction to DDD by Dax Raad.
Every example is a separate stack. The project contains the following stacks:
PolicyStack
- contains infrastrcuture for the policy service. It is intended to be used to update or enforce AWS policies e.g. change the retention of log groups globally or enforce a specific tag on all resources. This stack demonstrates the usage of the Event Bridge Scheduler and Lambda.
- The CDK still has some problems with a monorepo setup. You need to install
esbuild
on the root of the project in order to build yourNodeJSFunctions
. See this pr