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.
nodejs
, this is going to be your project directory. The name must be nodejs
.npm init
inside of this directory. npm install --save
. Note: local install is important.nodejs
directory and upload it to a Lambda
Layer. 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.
Yes, you simply need to bundle the latest version of the SDK in your Lambda function's deployment file, instead of relying on the version that is there.
On Default Lambda uses these SDKs AWS SDK for JavaScript – 2.290.0 SDK for Python (Boto3) – 3-1.7.74 botocore-1.10.74
But you can install the newest SDK via npm (or whatever you are using) and then upload the whole bunch of files to lamda.
Take a look at SLS (serverless Framework) it is easy to add files you want to deploy ;)
https://serverless.com/framework/docs/providers/aws/
https://serverless.com/framework/docs/providers/aws/guide/packaging/
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