'How do you share common code between AWS EKS and AWS lambdas?

We're deploying our ExpressJS API with AWS EKS. To avoid having a monolith we want to start extracting some functionalities into AWS lambdas. But the issue is that we have a lot of "connector-code" that's needed also in the lambda functions such as

  • Mongoose connection handling
  • Mongoose database schemas/models
  • etc.

How can I share this code between Lambdas and the API on EKS? I have read about AWS Layers but that seems to only work when sharing between lambdas exclusively. The only other way I can think of is having an internal NPM registry and then install it via npm modules on both sides. But I was wondering if there's any better solution to the problem?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source