将整数参数传递给 AWS StepFunction 会导致无效的状态机定义

Passing in integer parameter to AWS StepFunction causes Invalid State Machine Definition

我正在使用无服务器框架堆栈定义一个等待类型的步骤函数,它将变量作为其超时设置,如下所示:

WaitForReview:
  Type: Task
  TimeoutSeconds: $.submission.duration
  Resource: 'arn:aws:states:#{AWS::Region}:#{AWS::AccountId}:activity:${self:service}-${opt:stage}-activity_waitForReview'
  Next: HowToProceed
  ResultPath: '$.submission'
  Catch:
    - ErrorEquals:
        - States.Timeout
      ResultPath: '$.error'
      Next: CreditArtistAccount

这里重要的是 $.submission.duration。它应该是一个整数,但是当我尝试部署我的堆栈时,出现以下错误:

Invalid State Machine Definition: 'SCHEMA_VALIDATION_FAILED: Expected value of type Integer at /States/WaitForReview/TimeoutSeconds' (Service: AWSStepFunctions; Status Code: 400; Error Code: InvalidDefinition; Request ID: bb1a13c2-12cb-11e9-b1f0-4f37f70268ef)

有谁知道我如何从堆栈中获取变量并将其传递给 step 函数并在我这样做时将其设为整数?

State Task 字段 TimeoutSeconds 必须是 documentation 中定义的非零正整数。您不能使用状态路径来定义 TimeoutSeconds。如果设置,一般很可能与资源函数超时相同。