如何使用 aws cdk 打字稿创建 aws 步骤函数?

问题描述

我想使用 aws cdk typescript 创建以下步骤函数。 这是代码片段截图:

enter image description here

我在打字稿中尝试了以下代码

const finalStep = new sfn.Pass(this,'FinalStep');
    
    const fallBackJson={
      Type: "Task",Resource: "lambdaARN",ResultPath: "$.taskresult",InputPath: "$",Next: "FinalStep"
    };
    // States language JSON to put an item into DynamoDB
    // snippet generated from https://docs.aws.amazon.com/step-functions/latest/dg/tutorial-code-snippet.html#tutorial-code-snippet-1
    const startRecordingJson = {
        Type: "Task",Resource: joinMeetingLambda.functionArn,Parameters: {
          "meetingId.$": "$.meetingId","projectId.$": "$.projectId","meetingURL.$": "$.meetingURL","subscriptionId.$": "$.subscriptionId","recordingAction": "start"
        },Retry: [
          {
            "ErrorEquals": [
              "RecordingFailedToStart"
            ],"IntervalSeconds": 1,"MaxAttempts": 5,"BackoffRate": 2
          }
        ],Catch: [
          {
            "ErrorEquals": [
              "RecordingFailedToStart"
            ],Next: "FallBack"
          }
        ]
    };
    
    // custom state which represents a task to insert data into DynamoDB
    const startRecordingState = new sfn.CustomState(this,'InvokeRecording',{
      stateJson: startRecordingJson,});
    const fallBackState = new sfn.CustomState(this,'FallBack',{
      fallBackJson,});
    
     const chain = sfn.Chain.start(startRecordingState)
           .next(finalStep)
     const sm = new sfn.StateMachine(this,'StateMachine',{
  deFinition: chain,timeout: cdk.Duration.seconds(30),});
运行部署时出现以下错误

Invalid State Machine DeFinition: 'SCHEMA_VALIDATION_Failed: The field 'Type' is required at /States/FallBack'

希望我能得到一些帮助。这是来自 aws 的状态图:

enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)