Skip to content

AWS step functions StringEquals empty check #7803

@muscularjacky

Description

@muscularjacky

Q1: Describe the issue
I am using AWS Step Functions to create state machines and AWS CodeBuild to deploy the state machines via Serverless framework. In one of the state machines, I have written the code to check whether the input variable is empty or not. The code is simple and working if written directly on AWS step functions console page. But when the code is written in the yaml file and deployed using Serverless then I am getting an error.

code (in yaml):

name: "state-machine1"
role: "roleName"
definition:
  StartAt: VariableCheck
  States:
    VariableCheck:
      Type: Choice
      Comment: "Check if input variable is empty or not"
      Choices:
        - Not:
          - Variable: $.variableName
            StringEquals: "" (getting error here, I think you can't check an empty string in Serverless)
          Next: SomeState1
        - Variable: $.variableName
          StringEquals: ""
          Next: SomeState2
      Default: Unknown
    SomeState1:
      Type: Pass
      End: true
    SomeState2:
      Type: Pass
      Next: SomeState1
    Unknown:
      Type: Fail
      Comment: "If any unknown state it reaches"
      Cause: Reached unknown state
      Error: Reached unknown state
serverless.yml
frameworkVersion: ">=1.1.0 <2.0.0"

plugins:
  - serverless-aws-documentation
  - serverless-domain-manager
  - serverless-step-functions
  - serverless-pseudo-parameters

provider:
  name: aws
  stage: ${opt:stage, 'user'}
  stackName: stackName
  apiName: apiName
  runtime: go1.x
  versionFunctions: false
  region: us-west-2
  role: roleName
  deploymentBucket:
    name: bucketName
    serverSideEncryption: AES256

 individually: true
 exclude:
  - ./**

stepFunctions:
  stateMachines:
    State-Machine1:
      ${file(step_functions/state-machine1.yaml)}
serverless deploy output
Serverless Error ---------------------------------------
--
1140 |  
1141 | An error occurred: StateDashMachine1 - Invalid State Machine Definition: 
'SCHEMA_VALIDATION_FAILED: Expected value of type [OBJECT] at 
/States/VariableCheck/Choices[0]/Not' (Service: AWSStepFunctions; Status Code: 400; Error 
Code: InvalidDefinition; Request ID: b45dc9a9-b5a2-4d3d-add8-14c8075aa4fc; Proxy: null).

Installed version

serverless@1.52.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions