Monorepo setup for Serverless Microservices Architecture

Sohit kumar
Sep 4, 2019 · 2 min read

For one of the projects at Nggawe Nirman, we were having multiple services in microservices architecture and we were using API gateway and lambda for our services.

We were having our services in Monorepo, and deployment was done by automatically zipping the artifacts and pushing it to s3, but as we started using different features for API gateway, lambda and other services the setup task became manual and started taking too much time that is when we decided to use Serverless framework for our deployments.

As we were having our projects in Monorepo, our project structure looked something like this.

monrepo project structure.

The common package holds all the common utils, libraries which will be shared across all the services and helps to maintains common standards across different services and promotes shared learning accross services.

Each service will have there serverless.yml for the deployments at the root directory. Example serverless_app1 service will have app1_serverless.yml at the root directory.


serverless config for service app1 “app1_serverless.yml” will only include common and serverless_app1 packages, and it will exclude other services as shown in the image above.

To deploy a particular service, we call below command from the root directory of our monorepo

serverless deploy --config app1_serverless.yml

It generates the state file in .serverless directory, during deployments we manage the state file for each service and push it to s3.

Your deployment pipeline for each service will look something like this.

  1. Pull state file from s3 for the given service.
  2. serverless deploy — config serverless_yml_for_given_service.yml.
  3. Push and replace the state file on s3.

As of now, this is serving us well, Please let us know if you think if we can improve this or if you have any better strategy to deploy serverless projects in Monorepo.

You can connect to me here

Nggawe Nirman Tech Blog

Tech@Nggawe Nirman (

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store