简体   繁体   English

如何将 aws-sdk-js 捆绑到无服务器框架优化包中?

[英]How do you bundle aws-sdk-js into a Serverless Framework optimized package?

AWS SDK for node.js can not be run through browserify due to how the SDK is loaded由于SDK 的加载方式, AWS SDK for node.js 无法通过browserify运行

I want to included a newer version of the AWS SDK for node then what is included in lambda but I also want to optimize (via browserify) my lambda node.js code.我想包含一个较新版本的 AWS SDK for node 然后包含在 lambda 中,但我也想优化(通过 browserify)我的 lambda node.js 代码。

How do I pull this off?我该如何解决这个问题?

The JAWS AWS Module system (aka awsm) allows for this functionality via an attribute in the awsm.json metadata file that specifies how the lambda code is packaged. JAWS AWS 模块系统(又名 awsm)通过 awsm.json 元数据文件中的一个属性来实现此功能,该属性指定了 lambda 代码的打包方式。

Specifically the lambda.package.optimize.exclude and lambda.package.optimize.includePaths defined in the lambda configuration options section of the awsm.json spec.特别是lambda.package.optimize.exclude规范的lambda 配置选项部分中定义的lambda.package.optimize.excludelambda.package.optimize.includePaths

The exclude attribute specifies node modules that should be excluded from the optimization process (under the covers it is just using browserify exclude ). exclude属性指定应该从优化过程中排除的节点模块(在幕后,它只是使用browserify exclude )。 In the exclude attribute you simply specify ['aws-sdk'] .exclude属性中,您只需指定['aws-sdk'] You must then tell JAWS to include aws-sdk in the zip by putting its path in includePaths .然后,您必须通过将其路径放在includePaths来告诉 JAWS 将aws-sdk包含在 zip 中。

The includePaths attribute is a list of paths relative to the back directory that are pulled in as-is into the zip file before deployment. includePaths属性是相对于back目录的路径列表,这些路径在部署之前按原样拉入 zip 文件。

For a complete example see the awsm sample有关完整示例,请参阅awsm 示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 aws-sdk-js 列出日期范围内的对象? - How to list objects in a date range with aws-sdk-js? aws-sdk-js ReferenceError:您正在尝试在 Jest 环境被拆除后“导入”文件 - aws-sdk-js ReferenceError: You are trying to `import` a file after the Jest environment has been torn down 将aws-sdk-js与CognitoSync服务一起使用时出现InvalidSignatureException - InvalidSignatureException while using aws-sdk-js with CognitoSync service 使用AWS-SDK-JS访问AWS ELB服务时配置CORS - Configure CORS when accessing AWS ELB service using AWS-SDK-JS 使用 AWS-SDK-JS 使用普通 Javascript 将大文件作为流上传到 s3 - Upload large files as a stream to s3 with Plain Javascript using AWS-SDK-JS 使用AWS-SDK-JS通过CloudFront分发进行S3分段上传 - S3 Multipart upload via cloudfront distribution with aws-sdk-js 使用angular + aws-sdk-js +预签名网址将文件上传到S3 - Uploading a file to S3 with angular + aws-sdk-js + pre-signed url aws-sdk-js DynamoDB引发错误:Request.VALIDATE_REGION的配置中缺少凭据 - aws-sdk-js DynamoDB throwing Error: Missing credentials in config at Request.VALIDATE_REGION aws-sdk-js E2 createVPC 在等待添加 promise 时执行了两次 - aws-sdk-js E2 createVPC is executed twice while waiting adding a promise 为什么无服务器框架不包含 aws-nodejs 模板的 package.json - why does serverless framework not include package.json for aws-nodejs template
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM