Do I have to install the axios module locally and then deploy it to lambda or is there a way to do it through the inline code editor as well in the browser?
If you are not using any other libraries, you can directly edit your code and save it. However if you are using libraries like lodash or axios, you will not be able to install the packages directly. To do that, create function on our local machine with all the libraries and then upload it to the AWS Lambda.
Like this, we can call any REST API in our Lambda Function and perform any serverless operations on the response. To know more about Lambda functions and get a hand over the complete working code, please visit our Github Repository here.
You can publish a simple Node.js AWS Lambda layer with axios package and then attach created layer to your lambda.
List of commands to create .zip file for layer:
mkdir nodejs
cd nodejs
npm i axios
rm -rf package-lock.json
cd ..
zip -r axios.zip nodejs
This list of commands was taken from this article https://ljmocic.medium.com/publish-simple-node-js-aws-lambda-layer-a87c00afdd83
Create Layer Take Layer ARN Attach Layer to Lambda
Lambda doesn't actually bundle your package dependencies for you, except the AWS package, so yes you'd need to install it locally, zip it together and upload to the Lambda console.
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