我正在使用Lambda中的AWS Transfer for SFTP API设置SFTP流程。我遵循了文档中的示例以及在网上找到的有限示例,但是仅收到“ AWS.Transfer不是构造函数”错误消息。这是一个简单的示例:
const AWS = require('aws-sdk')
const transfer = new AWS.Transfer({
apiVersion: '2018-11-05',
region: `us-west-2`
});
const params = {
ServerId: 'hlaoslloesses' /* required */
};
transfer.describeServer(params, (err, data) => {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
错误消息:
Response:
{
"errorMessage": "AWS.Transfer 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)"
]
}
Request ID:
"ced0c74a-d81a-42b0-94a1-3e667921f7c4"
Function Logs:
START RequestId: ced0c74a-d81a-42b0-94a1-3e667921f7c4 Version: $LATEST
module initialization error: TypeError
at Object.<anonymous> (/var/task/index.js:3:18)
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)
END RequestId: ced0c74a-d81a-42b0-94a1-3e667921f7c4
REPORT RequestId: ced0c74a-d81a-42b0-94a1-3e667921f7c4 Duration: 79.81 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 67 MB
module initialization error
TypeError
我尝试通过API和SDK docs修改示例,但仍然得到相同的结果。有没有人得到这个工作?
答案 0 :(得分:1)
AWS Transfer相对较新。 Node 8.10 Lambda运行时正在运行SDK的2.290.0版本,其中不包括AWS.Transfer。
您可以在当前运行2.437.0的Node10.x运行时上部署功能,也可以将新版本的JS SDK与功能代码打包在一起。
以下是供以后参考的链接:https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html