Receiving TypeError: AWS.RDSDataService is not a constructor

Receiving TypeError: AWS.RDSDataService is not a constructor

正在尝试在 AWS Lambda 中使用 RDSDataService,如下所示:

const AWS = require('aws-sdk');

AWS.config.update({
  region: 'us-east-1'
})
AWS.config.apiVersions = {
  rdsdataservice: '2018-08-01',
  // other service API versions
};

const rdsdataservice = new AWS.RDSDataService();

exports.handler = function(event, context, callback) {
  callback(null, 'ok')      
};

接收错误:

"errorMessage": "AWS.RDSDataService is not a constructor", "errorType": "TypeError", "stackTrace": [ "Module._compile (module.js:652:30)", "Object.Module._extensions..js (module.js:663:10)", "Module.load (module.js:565:32)", "tryModuleLoad (module.js:505:12)", "Function.Module._load (module.js:497:3)", "Module.require (module.js:596:17)", "require (internal/module.js:11:18)"

Nodejs 版本:8.10

知道发生了什么事吗?我设置了区域和 API 版本

它必须与最新的 aws-sdk 包一起使用。

您可以使用此命令检查软件包版本:

npm show aws-sdk version

您可以在此处查看已发布的版本:https://www.npmjs.com/package/aws-sdk