Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Functions common to several lambda

I have a project under NodeJS and hosted on AWS, and I have several functions that I would like to use in several lambdas, without having to copy and paste. Currently, I run a shell at build time that copies all these files, but the drawback is that all the packages I use must also be installed in all these lambdas.

So I’d like to know if there’s a much cleaner way of doing this or not.

PS: The build is done via Github Actions

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can either:

  • Use Lambda layers so that you can freeze the dependency versions, reduce the weight of each lambda and avoid repetitive code base. It allows you to reduce the repetitive code on functions that would utilize it. One downside though is that if something gets messed up inside the layers, the importing functions will all get affected.
  • Bundle, minify and treeshake your NodeJS (Easier to implement in TypeScript) functions before deploying them to AWS lambda.
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading