amazon-web-servicesaws-lambdaserverless-frameworkaws-step-functionsaws-serverless

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


I’m defining a waiting type step function with the serverless framework stack that takes a variable as its timeout setting, like so:

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

The one that matters here is $.submission.duration. It’s supposed to be an integer, but when I try to deploy my stack I get the follow error:

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)

Does anyone know how I can grab a variable from the stack and pass it in to the step function and have it be an integer when I do so?


Solution

  • State Task field TimeoutSeconds must be a positive, non-zero integer as defined in the documentation. You cannot use state path to define the TimeoutSeconds. If set, generally it is likely to be identical to the resource function timeout.