sinanbekar / turborepo-cdktf-microservices-app

(POC) Monorepo that includes serverless microservices using AWS Lambda and Amazon MQ (RabbitMQ) for backend, Vercel for frontend (Next.js) with Terraform CDK infrastructure.

Home Page:https://turborepo-cdktf-microservice-app.vercel.app/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Turborepo CDKTF Microservices App

Monorepo using serverless microservices design with AWS Lambda and Amazon MQ (RabbitMQ) for backend, Vercel for frontend (Next.js) with Terraform CDK infrastructure.

What's inside?

This turborepo uses pnpm as a packages manager. It includes the following packages/apps:

Apps and Packages

  • csv-to-pdf-microservice: a python microservice that converts csv to pdf with RabbitMQ & kombu (messaging library)
  • aggregation: a Nestjs backend for frontend (Lambda function)
  • web: Next.js app
  • eslint-config-custom: eslint configurations (includes eslint-config-next and eslint-config-prettier)
  • tsconfig: tsconfig.jsons used throughout the monorepo

Notes

  • The infrastructure targets minimum cost (free) and does not include best practices for security. If you want to use it for large production you should create a VPC with private & public subnets with NAT Gateway (or VPC Endpoint PrivateLink) to establish a connection between API Gateway, Amazon MQ (set publicly accessible to false), STS, SecretsManager, and AWS Lambda. If you use VPC Endpoint (PrivateLink) for communication between these services, the traffic won't go on the public internet, it stays on AWS Network and this will help maximum security for your application.
  • Besides requests between microservice and frontend, the file sharing between Lambdas is provided with a message queue. (we are working with files less than 100 KB, and for staying free tier) You should not use a message queue for sharing file binary in large production, instead, you should use a reference path. For a serverless (AWS Lambda) environment, you can use EFS or S3. You can find additional information in application code comments.

Utilities

This turborepo has some additional tools already setup for you:

Setup

git clone https://github.com/sinanbekar/turborepo-cdktf-microservices-app
cd turborepo-cdktf-microservices-app
pnpm install

Build

To build all apps and packages, run the following command:

pnpm run build

Deployment

To deploy frontend to Vercel, backend to AWS (Lambda), first install cdktf-cli:

pnpm add --global cdktf-cli@latest
cd infrastructure/cdktf
cdktf get # generate constructs from hcl providers

Please make sure that set up these environment variables: AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY and VERCEL_API_TOKEN

and deploy 🚀

cdktf deploy backend frontend

Develop

To develop all apps and packages, run the following command:

pnpm run dev

Useful Links

Learn more about Terraform and CDK for Terraform:

Learn more about the power of Turborepo:

About

(POC) Monorepo that includes serverless microservices using AWS Lambda and Amazon MQ (RabbitMQ) for backend, Vercel for frontend (Next.js) with Terraform CDK infrastructure.

https://turborepo-cdktf-microservice-app.vercel.app/


Languages

Language:TypeScript 76.0%Language:JavaScript 15.3%Language:Python 8.4%Language:CSS 0.3%