You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何配置AWS Step Functions可配置等待时长?CloudFormation报错解决

解决AWS Step Functions Wait状态动态等待时长的JSON解析与类型校验问题

问题根源在于Step Functions状态机定义的语法使用错误:直接在Seconds字段写JSONPath表达式会导致JSON解析失败,加引号后又会触发类型校验错误。正确的处理方式是使用Step Functions的动态字段引用语法,通过字段名.$的格式指定JSONPath表达式:

修正后的状态机代码片段

StepFunctionsStateMachine:
    Type: AWS::StepFunctions::StateMachine
    Properties:
      StateMachineName: userNotificationPipeline
      DefinitionString: !Sub |
        {
          "Comment": "A description of my state machine",
          "StartAt": "Wait",
          "States": {
            "Wait": {
              "Type": "Wait",
              "Seconds.$": "$.Input.Timer",
              "Next": "Lambda Invoke"
            },
            "Lambda Invoke": {
              "Type": "Task",
              "Resource": "arn:aws:states:::lambda:invoke",
              "OutputPath": "$.Payload",
              "Parameters": {
                "FunctionName": "endUserNotificationReminder",
                "Payload.$": "$"
              },
              "End": true
            }
          }
        }

关键说明

  • Seconds.$是Step Functions的标准语法,用于指定从输入数据中动态获取等待秒数的JSONPath路径。这种写法既符合JSON格式要求(作为字符串值),又能让Step Functions解析后将结果识别为整数类型,满足Wait状态对Seconds字段的类型约束。
  • 需确保$.Input.Timer对应的输入值为整数类型,否则仍会触发类型校验错误。

内容的提问来源于stack exchange,提问作者acoordes

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.27 11:02:09