AWSCDKStepFunctions-ResponseAlwaysNull
创始人
2024-09-24 03:00:38
0

首先,需要确保您的 AWS CDK Step Functions 定义中的每个状态都设置了正确的返回值。其次,您需要使用正确的 step function 调用方式来返回这些返回值。

下面是一个示例:

import * as cdk from 'aws-cdk-lib';
import * as sfn from 'aws-cdk-lib/aws-stepfunctions';
import * as tasks from 'aws-cdk-lib/aws-stepfunctions-tasks';
const stack = new cdk.Stack(app, 'MyStack');

const stateMachine = new sfn.StateMachine(stack, 'StateMachine', {
  definition: new tasks.LambdaInvoke(stack, 'Task', {
    lambdaFunction,
    // Set the task's input and output path
    outputPath: '$.Payload',
  }),
});

const task = new sfn.Task(stack, 'Task', {
  task: new tasks.LambdaInvoke(stack, 'MyLambda', {
    lambdaFunction: fn,
    outputPath: '$.Payload',
  }),
  // Define the state's output path
  outputPath: '$.Payload',
});

const definition = new sfn.Choice(stack, 'Make a choice')
  .when(sfn.Condition.stringEquals('$.status', 'success'), task)
  .when(sfn.Condition.stringEquals('$.status', 'failure'), sfn.Fail(stack, 'Failed', { error: 'The task failed!' }))
  .otherwise(sfn.Fail(stack, 'Invalid status!', { error: 'The status is not valid!' }));

const stateMachine = new sfn.StateMachine(stack, 'MyStateMachine', {
  definition,
});

// Invoke the state machine
const invoker = new sfn.StateMachine(stack, 'MyInvoker', {
  stateMachine,
});

// Call the state machine using Lambda
const lambda = new lambda.Function(stack, 'MyLambdaFn', {
  code,
  handler: 'handler.handler',
  runtime: lambda.Runtime.NODEJS_12_X,
  environment: {
    STATE_MACHINE_ARN: stateMachine.stateMachineArn,
  },
});

// Grant permission to invoke the state machine from this Lambda function
stateMachine.grantStartExecution(lambda);

请注意,上述示例中的每个状态都设置了正确的输出路径,并且使用正确的 step function 调

相关内容

热门资讯

开挂辅助神器"wep... wepoker透视app下载开挂教程视频分享装挂详细步骤在当今的网络游戏中,wepoker透视app...
开挂辅助工具"hhp... 开挂辅助工具"hhpoker有没有辅助挂"开挂(透视)辅助下载(有挂解密);无需打开直接搜索加薇13...
开挂辅助平台"har... 【亲,hardrock辅助 这款游戏可以开挂的,确实是有挂的,很多玩家在这款hardrock辅助中打...
开挂辅助神器"拱趴大... 开挂辅助神器"拱趴大菠萝挂"开挂(透视)辅助插件(真的有挂)《详细加薇136704302咨询》游戏特...
开挂辅助神器"wep... 开挂辅助神器"wepoker私人局怎么玩"开挂(透视)辅助脚本(有人有挂);无需打开直接搜索加(薇:...
开挂辅助安装"wep... 开挂辅助安装"wepoker黑侠破解"开挂(透视)辅助工具(有挂猫腻)《详细加薇136704302咨...
开挂辅助平台"wpk... 开挂辅助平台"wpk有辅助吗"开挂(透视)辅助脚本(有挂实锤)>>您好:软件加136704302中薇...
开挂辅助软件"we-... 较多好评“微乐万能挂官网”开挂(透视)辅助教程 了解更多开挂安装加(136704302)微信号是一款...
开挂辅助软件"智星德... 开挂辅助软件"智星德州插件怎么下载"开挂(透视)辅助软件(讲解有挂);无需打开直接搜索薇:13670...
开挂辅助下载"拱趴游... 开挂辅助下载"拱趴游戏破解器"开挂(透视)辅助平台(有挂分析);无需打开直接搜索加薇13670430...