2

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!

2
  • Yes, you can create a layer with your common code and share it between your functions. There is official AWS documentation about how to do this: docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html Commented May 24, 2022 at 16:11
  • but my functions didn't generate this folder nodejs/node_modules Commented May 24, 2022 at 16:40

1 Answer 1

3
  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:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.