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?

Thank you!



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.

  1. Create a directory named nodejs, this is going to be your project directory. The name must be nodejs.
  2. Perform npm init inside of this directory.
  3. Install all the libraries from npm using npm install --save. Note: local install is important.
  4. Once done, zip up the nodejs directory and upload it to a Lambda Layer.
  5. 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.