【问题标题】:AWS CDK Step Functions - Response Always NullAWS CDK Step Functions - 响应始终为空
【发布时间】:2022-09-23 07:18:01
【问题描述】:

我正在使用 AWS CDK Step Function 构造来创建一个简单的工作流。我可以很好地调用第一个 Lambda,然后调用下一个 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 \'bulk summary task\' 得到的响应始终为空。我不清楚为什么我会变得空,而且我不知道为什么。任何想法都会有很大帮助。

        {
      \"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
    }

    标签: amazon-web-services aws-cdk aws-step-functions


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2021-08-27
      • 1970-01-01
      • 1970-01-01
      • 2020-09-05
      • 2020-01-29
      • 1970-01-01
      • 2022-12-21
      • 1970-01-01
      • 2019-04-24
      相关资源
      最近更新 更多