我试图在另一个lambda函数中调用aws lambda函数。我尝试了一个非常简单的代码片段。但是,每次我收到“TypeError:lambda.invoke都不是函数”。
这是我的代码:
exports.handler = function(event, context) {
var AWS = require('aws-sdk');
AWS.config.apiVersions = {
lambda: '2015-03-31',
// other service API versions
};
var lambda = new AWS.Lambda();
var params = {
FunctionName: "node-sendsms",
InvocationType: "Event",
LogType: "Tail",
Payload: null
};
lambda.invoke(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
};
我在这里提到了调用函数的文档:http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html#invoke-property 并遵循相同的代码。我尝试更改api版本,但这没有帮助。我也尝试在网上和SO上寻找任何解决方案;至少我得到的信息是它可能是AWS变量的变量范围问题。但是,正如在代码中可以看到的那样 - 它似乎不是那样的。
有关此错误的专家吗?我正在研究node.js 6.10。这是错误细节:
Response:
{
"errorMessage": "RequestId: 849581c1-d669-11e7-ad15-6f5e52f0e184 Process exited before completing request"
}
Request ID:
"849581c1-d669-11e7-ad15-6f5e52f0e184"
Function Logs:
START RequestId: 849581c1-d669-11e7-ad15-6f5e52f0e184 Version: $LATEST
2017-12-01T07:30:35.785Z 849581c1-d669-11e7-ad15-6f5e52f0e184 TypeError: lambda.invoke is not a function
at exports.handler (/var/task/index.js:22:9)
END RequestId: 849581c1-d669-11e7-ad15-6f5e52f0e184
REPORT RequestId: 849581c1-d669-11e7-ad15-6f5e52f0e184 Duration: 1385.62 ms Billed Duration: 1400 ms Memory Size: 128 MB Max Memory Used: 24 MB
RequestId: 849581c1-d669-11e7-ad15-6f5e52f0e184 Process exited before completing request
答案 0 :(得分:0)
安装最新版本的aws sdk或提及类似内容
exports.handler = (event, context, callback) => {
var AWS = require('aws-sdk');
AWS.config.apiVersions = {
lambda: '2015-03-31' ///ignore if latest version
};
var lambda = new AWS.Lambda();