Home > Net >  How to share my own custom fucntions on AWS lambda nodejs
How to share my own custom fucntions on AWS lambda nodejs

Time:05-25

I Currently have a project in AWS with several lambda functions, most of the functions in NodeJS, I want to know if is there a way to create a lambda layer with my own code functions that I use in different lambdas without publish it in npm, I already search in old questions in stack question-1 question-2, but these were not answered

Thanks for help!

CodePudding user response:

  1. create a folder in your local machine called nodejs
  2. put your "shared" logic in that folder like /nodejs/shared.js
  3. you can zip this nodejs folder and upload as a layer
  4. in your lambda code require the shared.js as const shared = require('/opt/nodejs/shared.js')

Links:

  • Related