Lambda layers were introduced in 2018 for flexibel code/data sharing within same or different AWS accounts. AWS Lambda supports multiple environ...
For further actions, you may consider blocking this person and/or reporting abuse
Am I able to bundle all but one of my dependencies in with the lambda handler code using webpack but then put that one dependency in a layer? I'd prefer to only use a layer for a hefty dep that is unlikely to change and keep the rest bundled with the handler code.
Agreed! Common use cases for layers involve heavy dependencies that are shared across multiple Lambda functions.
In case anyone is wondering about this step: "index.js file that exports all node modules", here's what I did:
bro, you save my life! hahah
glad to hear this :)
This uploads en entire node_modules which is fine for smaller projects, but when the project size is 300 Lambdas, with a lot of dependencies, it exceeds the 250mb limit even without development dependencies. Do you have any suggestions on if it's possible to utilise tree shading, and some sort of import method to only put the methods you use instead of entire libraries into the layer?
This looks possible only with your own custom packages, I don't know any technique to pick and choose the methods for 3rd party deps you are using in your code.
About the lambda deployment-package limit, I have two suggestions:
Thanks for the info, if I need to use models for my database and export my modules containing the query functions, should I keep it in my node_modules folder or outside of it, inside the nodejs folder, making the structure look like this-
nodejs
-node_modules
-custom-module1
-custom-module2
You need to put your custom moduels into the node_modles folder. Nothing else should be there in nodejs folder like below
_ nodejs
__ node_modules
___ module0
___ module1
___ module2
.
.
.
Are we supposed to replace
file-name
in the build command?yes :)