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 调

相关内容

热门资讯

第4分钟实锤!德州ai辅助有用... 第4分钟实锤!德州ai辅助有用(德州app)切实真的有挂(详细辅助科技教程);1、上手简单,内置详细...
第6分钟实锤!智星德州菠萝(德... 第6分钟实锤!智星德州菠萝(德扑)果然真的有挂(详细辅助必备教程)1)智星德州菠萝辅助挂:进一步探索...
第5分钟实锤!德扑之星作弊(w... 第5分钟实锤!德扑之星作弊(wpk德州)果然是有挂(详细辅助必赢教程)1)德扑之星作弊辅助挂:进一步...
一分钟实锤!德州ai辅助有用(... 一分钟实锤!德州ai辅助有用(德扑ai)原来真的是有挂(详细辅助新版2025教程);1、打开软件启动...
第2分钟实锤!德扑之星作弊(来... 第2分钟实锤!德扑之星作弊(来玩德州)一直真的有挂(详细辅助玩家教程)1、上手简单,内置详细流程视频...
六分钟实锤!德州ai辅助软件(... 六分钟实锤!德州ai辅助软件(手机德州)其实有挂(详细辅助科技教程)1、玩家可以在德州ai辅助软件软...
3分钟实锤!德扑数据软件(德扑... 3分钟实锤!德扑数据软件(德扑之星)本来有挂(详细辅助攻略教程)进入游戏-大厅左侧-新手福利-激活码...
第1分钟实锤!智星德州菠萝外挂... 第1分钟实锤!智星德州菠萝外挂(德州wpk)总是存在有挂(详细辅助教你教程)暗藏猫腻,小编详细说明智...
9分钟实锤!德扑起手牌胜率图(... 9分钟实锤!德扑起手牌胜率图(德州)确实是有挂(详细辅助AA德州教程);1、金币登录送、破产送、升级...
第1分钟实锤!德扑之星ai代打... 第1分钟实锤!德扑之星ai代打(德州wpk)竟然真的有挂(详细辅助曝光教程)1、玩家可以在德扑之星a...