You can install any Node.js dependency and use it in AWS lambda.
In this tutorial we will show you step by step guide on how to use node js modules/libraries inside your AWS lambda function.
To do this you must create a new Node.js project in an IDE, in this tutorial we will be using Visual Code Studio.
1) Create a node project in VS code.
npm init
2) Now from terminal install any dependency you might want to use in your AWS lambda function. (In this tutorial we will be installing MySQL and be using it in Lambda).
npm install mysql
3) After the dependencies are installed, you can create a new JS file named as “index.js” and write the standard code here.
4) After you are done installing every dependency that you want to use in your lambda function, you can simply select these files from the directory and add them to archive. (Please note , the archive must be in .zip format)
5) Now go to your lambda function and on the right side, click on Upload from, there select “.zip file” and you can upload your zip file into lambda.
6) Now you can import and use any dependency you might wanna use in your AWS lambda function.