AWS Lambda: how to share code between functions in a monorepo

Click for: original source

Yan Cui put together this tutorial about sharing business logic between services in a Node.js monorepo.

His advise can be summarized like this:

  • Encapsulate the shared business logic into modules, and put them in a separate folder
  • In the Lambda handler functions, reference the shared modules using relative paths
  • Use webpack to resolve and bundle them into the deployment package
  • Deploy every service on every commit

Loads of code examples together with deployment script included. And To see how everything fits together, check out this demo repo. It has CI/CD set up already through drone.io. Nice one!

[Read More]

Tags serverless containers aws web-development javascript