I've started using AWS Lambda for a small site. I will have around 10-15 lambdas connected to different triggers (API's, SQS etc.)
We are going to use AWS SAM for creating our stacks and NodeJS for most of the lambda methods.
I've searched a lot to find the best practices for the node_modules and couldn't really get to a conclusion. Most of the proposed solutions included layers and I couldn't really understand how I should build those layers and how they work side by side with local testing.
Questions:
Whats the difference between using the node_modules "as is" and converting the node_modules directory to a layer? Will it benefit performance wise? Will it benefit only when a cold lambda is loaded?
If layers is the solution, should I use one layer for all lambdas (e.g. some kind of CI script that will "merge" them pre deploy)? Or create a mono-repo solution using all the same node_module versions across all lambdas? This seems a bit not clean but I have seen recommendations like these while searching for the best solution.
I'm looking for a decent solution that will not hurt performance wise and an option to work locally and test our code before deploying it..