/cdk-monorepo

Introduction to showcase the usage of AWS CDK with Turborepo in a DDD way.

Primary LanguageTypeScript

CDK Examples

This project demonstrates how to use AWS CDK with Turborepo and DDD.

Goals

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.

Project Structure

The project is structured as follows:

  • iac/ - contains the CDK project and everything related to the backend infrastructure
  • packages/ - 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.

test

Stacks

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.

FYI

  • 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 your NodeJSFunctions. See this pr