微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决如何使用 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 举报,一经查实,本站将立刻删除。