我正在使用 Amazon Transcribe 服务并尝试让 CloudWatch Events 触发一个 Lambda 函数,该函数对我的 API 执行 POST 请求。
这是 Lambda 函数
var querystring = require('querystring');
var http = require('http');
exports.handler = function(event, context) {
var post_data = querystring.stringify(
event
);
// An object of options to indicate where to post to
var post_options = {
host: '193e561e.ngrok.io',
port: '80',
path: '/api/lambda',
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(post_data)
}
};
// Set up the request
var post_req = http.request(post_options, function(res) {
res.setEncoding('utf8');
res.on('data', function(chunk) {
console.log('Response: ' + chunk);
context.succeed();
});
res.on('error', function(e) {
console.log("Got error: " + e.message);
context.done(null, 'FAILURE');
});
});
// post the data
post_req.write(post_data);
post_req.end();
}
我已将 CloudWatch Events 配置为侦听 Amazon Transcribe 服务,并专门针对更改为COMPLETED
或的作业状态FAILED
。
然而,令人惊讶的是,在该事件响应中没有提及转录作业名称。
这是一个例子:
'version' => '0',
'id' => '1fa5cca6-413f-4a0f-0ba2-66efa49c247e',
'detail-type' => 'Transcribe Job State Change',
'source' => 'aws.transcribe',
'account' => '405723091079',
'time' => '2019-11-19T19:04:25Z',
'region' => 'eu-west-1',
'detail' => NULL,
这是我认为我的应用程序在通过 Amazon Transcribe 服务调用转录作业的情况下工作的唯一方法,然后当它完成后,点击我的 API 以更新我的应用程序中的必要模型,但没有获取 Transcribe 作业名称,它赢了不行。
任何建议表示赞赏。