- Newest
- Most votes
- Most comments
Hello.
I think "aws-sdk" can be used by default with Lambda's Node.js, but what kind of modules are you specifically adding?
https://docs.aws.amazon.com/lambda/latest/dg/nodejs-package.html#nodejs-package-dependencies
For Lambda functions that use the Node.js runtime, a dependency can be any Node.js module. The Node.js runtime includes a number of common libraries, as well as a version of the AWS SDK for JavaScript. The nodejs16.x Lambda runtime includes version 2.x of the SDK. Runtime versions nodejs18.x and later include version 3 of the SDK. To use version 2 of the SDK with runtime versions nodejs18.x and later, add the SDK to your .zip file deployment package. If your chosen runtime includes the version of the SDK you are using, you don't need to include the SDK library in your .zip file. To find out which version of the SDK is included in the runtime you're using, see Runtime-included SDK versions.
If you can use AWS SAM, you can create "package.json" and create layers using SAM templates.
https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-layerversion.html
the answer about working this way
import { S3Client } from "@aws-sdk/client-s3";
was the way forward... it's a bit more fiddly than just importing everything... but, well worth the trade off of not having to upload zip files
Relevant content
- asked a year ago
- asked 2 years ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 4 months ago
- AWS OFFICIALUpdated 2 years ago
So, I've tried just adding my code into the index.mjs. The only import is: import AWS from 'aws-sdk'; But, when I test I get an error: "errorMessage": "Cannot find package 'aws-sdk' imported from /var/task/index.mjs",
You are probably using JavaScriptSDKV3, but how about specifying the service client and importing the SDK as shown below? https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/introduction/
The following GitHub issue is probably related. https://github.com/aws/aws-sdk-js-v3/issues/3230