Is It Possible To Use A Newer Version Of The Aws-sdk Than Provided In AWS Lambda?
The latest version of the aws-sdk has functions for ComprehendMedical, which I'd like to create a lambda function for.
However, the version of the AWS-SDK is a few months outdated, and not able to use these functions yet. Wondering if there is a way to use the latest library?
I recommend you create a Library bundle and create a Lambda Layer with it with the desired version of AWS-SDK in the Library bundle (including any other libraries that you want). Once you have the Lambda layer set you can assign it to your Lambda function(s). This helps with a reduced code size of your Lambda function without having the need to bundle up all the libraries you need with every single Lambda Function. Considering AWS-SDK to be a pretty large library, Lambda Layer will help you manage the size of your individual Lambda functions with purely your code in it.
The steps are simple.
- Create a directory named
nodejs, this is going to be your project directory. The name must be
npm initinside of this directory.
- Install all the libraries from
npm install --save. Note: local install is important.
- Once done, zip up the
nodejsdirectory and upload it to a Lambda Layer.
- Use the Lambda Layer in all your Lambda functions.
Check out my article for the full details on how to set up a Lambda Layer for Node JS dependencies. I reckon that going forward, Lambda Layer should be everyone's choice of dependency management in Lambda.
NOTE: Lambda Layer was introduced
recently in AWS re:Invent 2018. It is not only compatible with NodeJS, but also with pretty much any other Language (as per Amazon) like Python, Java, C#, C++ (yes!), Go, Rust etc.
- → Maximum call stack exceeded when instantiating class inside of a module
- → Browserify api: how to pass advanced option to script
- → Node.js Passing object from server.js to external modules?
- → gulp-rename makes copies, but does not replace
- → requiring RX.js in node.js
- → Remove an ObjectId from an array of objectId
- → Can not connect to Redis
- → React: How to publish page on server using React-starter-kit
- → Express - better pattern for passing data between middleware functions
- → Can't get plotly + node.js to stream data coming through POST requests
- → IsGenerator implementation
- → Async/Await not waiting
- → (Socket.io on nodejs) Updating div with mysql data stops without showing error