AWS CDK步骤功能-响应始终为空



我使用AWS CDK步骤函数构造来创建一个简单的工作流。我可以调用第一个Lambda fine,然后调用下一个Lambda。然而,在第二个Lambda上,我的输入和预期的一样好,但Lambda任务的输出总是返回Payload:null作为响应。我不打算这样做,我想通过输出键返回Lambda内部的数据,并将其传递给下一个任务。

export const bulkSummaryHandler = (event) => {
try {
console.log('LAMBA SUMMARY!', event);
return { output: { status: 'finished' } };
} catch (error) {
return handleError(error);
}
};

我的CDK代码

const getUserCsvFileTask = new tasks.LambdaInvoke(ctx.stack, 'getUserCsvFileTask', {
lambdaFunction: getUserCsvFileFn,
comment: 'fetch user uploaded csv from csv-integration-service',
inputPath: '$',
resultPath: '$.taskResult',
outputPath: '$.taskResult.Payload'
});


const bulkSummaryTask = new tasks.LambdaInvoke(ctx.stack, 'bulkProcessingSummaryTask', {
lambdaFunction: bulkSummaryFn,
comment: 'summarise bulk processing',
inputPath: '$'
});

const definition = stepfunctions.Chain.start(getUserCsvFileTask).next(bulkSummaryTask).next(nextLambdaTask);

我从Payload Key中调用的第二个Lambda"批量摘要任务"中得到的响应始终为null。我不清楚为什么我会变得无效,也不知道为什么。任何想法都会很有帮助。

{
"ExecutedVersion": "$LATEST",
"Payload": null,
"SdkHttpMetadata": {
"AllHttpHeaders": {
"X-Amz-Executed-Version": [
"$LATEST"
],
"x-amzn-Remapped-Content-Length": [
"0"
],
"Connection": [
"keep-alive"
],
"x-amzn-RequestId": [
"fed8b1bd-d188-4425-ade7-ce2723aef4c8"
],
"Content-Length": [
"4"
],
"Date": [
"Wed, 21 Sep 2022 22:54:00 GMT"
],
"X-Amzn-Trace-Id": [
"root=1-632b9607-0e451e4c5dd4c21c7a3eaa8b;sampled=1"
],
"Content-Type": [
"application/json"
]
},
"HttpHeaders": {
"Connection": "keep-alive",
"Content-Length": "4",
"Content-Type": "application/json",
"Date": "Wed, 21 Sep 2022 22:54:00 GMT",
"X-Amz-Executed-Version": "$LATEST",
"x-amzn-Remapped-Content-Length": "0",
"x-amzn-RequestId": "fed8b1bd-d188-4425-ade7-ce2723aef4c8",
"X-Amzn-Trace-Id": "root=1-632b9607-0e451e4c5dd4c21c7a3eaa8b;sampled=1"
},
"HttpStatusCode": 200
},
"SdkResponseMetadata": {
"RequestId": "fed8b1bd-d188-4425-ade7-ce2723aef4c8"
},
"StatusCode": 200
}

啊,我真是太愚蠢了。处理程序需要是异步的——没有回调,它不会返回任何内容。

export const bulkSummaryHandler = async (event) => {
try {
console.log('LAMBA SUMMARY!', event);
return { output: { status: 'finished' } };
} catch (error) {
return handleError(error);
}
};

最新更新