amplify-cli icon indicating copy to clipboard operation
amplify-cli copied to clipboard

Best way to share code between lambda functions

Open Jkap7788 opened this issue 7 years ago • 2 comments

** Which Category is your question related to? ** Functions

** What AWS Services are you utilizing? ** Lambda, S3

Hi, I was just wondering what the best way is to share code between lambda functions in Amplify. I am not sharing an entire library of code, more like some useful utility functions that house common business logic. I am aware of lambda layers but think they are overkill for this kind of use case.

I would love to be able to create a directory in the repo that contains common code and then 'require' that code in the lambda functions. Is there any way to require code outside the scope of the lambda function src directory and bundle that into the lambda code before deploying to the cloud?

Thanks a lot!

Jkap7788 avatar Sep 15 '19 03:09 Jkap7788

@Jkap7788 you've the some choices:

  • Copy the shared file as part of your build process
  • Use a monorepo with Lerna and consume the shared pieces as a package
  • Use lambda layers

Lambda layers is the one that CLI will support and it is tracked in #1696, so closing this as a duplicate.

attilah avatar Sep 17 '19 16:09 attilah

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.

github-actions[bot] avatar May 27 '21 02:05 github-actions[bot]