Recently I found that aws-sdk
NPM module is preinstalled in AWS Lambda nodejs8.10. And I can't find any information in the internet about it.
Which other node.js modules are pre-installed in AWS Lambda?
AWS Lambda natively supports Java, Go, PowerShell, Node. js, C#, Python, and Ruby code, and provides a Runtime API which allows you to use any additional programming languages to author your functions.
You can reuse the lambda layer for multiple functions. You can even include multiple npm modules or even your own helper functions that you reuse between your lambdas. You can use up to five layers in a single lambda function.
An Execution Environment is an invisible stack (a virtual machine — MicroVM) that provides and manages the resources required to run your Lambda Function. It also provides a lifecycle support for the Function's runtime and any external extensions associated with the Function.
You use a deployment package to deploy your function code to Lambda. Lambda supports two types of deployment packages: container images and . zip file archives. To create the deployment package for a .
Unfortunately the docs don't seem very specific about it, but you can grab their docker images yourself and bash in to inspect them:
docker run --rm -it --entrypoint /bin/bash amazon/aws-lambda-nodejs:14
The Dockerfile has ENTRYPOINT ["/lambda-entrypoint.sh"]
and by inspecting that file I was able to determine that it runs Node via /var/runtime/bootstrap
.
/var/runtime/bootstrap
adds various directories to NODE_PATH
from which modules can be loaded:
if [ -z "$NODE_PATH" ];
then
nodejs_mods="/opt/nodejs/node_modules"
nodejs14_mods="/opt/nodejs/node14/node_modules"
runtime_mods="/var/runtime/node_modules"
task="/var/runtime:/var/task"
export NODE_PATH="$nodejs14_mods:$nodejs_mods:$runtime_mods:$task"
fi
However /opt/nodejs
doesn't exist in the image and /var/task
is where Lambda puts your custom code.
So /var/runtime/node_modules
is the only directory we need to inspect:
bash-4.2# cd /var/runtime
bash-4.2# npm ls
/var/runtime
└─┬ [email protected]
├── [email protected] extraneous
├── [email protected] extraneous
├── [email protected] extraneous
├── [email protected] extraneous
├── [email protected] extraneous
├── [email protected] extraneous
├── [email protected] extraneous
├── [email protected] extraneous
└── [email protected] extraneous
As you can see, only aws-sdk
is preinstalled. But you could use this process to determine if they add more preinstalled deps in future versions of their Node.js runtime.
Only the aws-sdk package is preinstalled .
All the rest is loaded from the "node_modules" directory..
You can find information about it here:
https://docs.aws.amazon.com/lambda/latest/dg/nodejs-create-deployment-pkg.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With