I want to make a nodejs application that uses the AWS SDK. However, it only really needs to use S3, and I want the application to have a small filesize.
AWS has a custom sdk builder which should make a custom SDK with only the required packages. Unfortunately, this doesn't work, even when I select all of the services. How do I make a custom SDK that works with node?
I've tried using the npm install aws-sdk
, and that works, but it's 40MB. I've also tried selecting all of the services in the service builder (only 3MB), but that doesn't work.
It always gives an error at this line:
var aws = require("./aws-sdk-2.462.0.min.js");
ReferenceError: AWS is not defined
at Object.<anonymous> (/home/cwaugh/workspaces/meta-lambda/aws-sdk-2.462.0.min.js:7:30180)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/home/cwaugh/workspaces/meta-lambda/handler.js:5:11)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
This is now possible with AWS SDK for JavaScript v3
You can install only the required packages as follows :
npm install @aws-sdk/client-s3
Use them as :
const {S3} = require('@aws-sdk/client-s3');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.