Skip to content

bug: InvalidDefinition error when creating/updating State Machine #9771

@guillaume-macquat

Description

@guillaume-macquat

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

I'm trying to create a state machine using the following definition that I validated on AWS:

{
  "StartAt": "GetSuffix",
  "States": {
    "GetSuffix": {
      "Type": "Pass",
      "Parameters": {
        "suffix.$": "States.ArrayGetItem(States.StringSplit($$.StateMachine.Name, '-'), States.MathAdd(States.ArrayLength(States.StringSplit($$.StateMachine.Name, '-')), -1))"
      },
      "End": true
    }
  }
}

It fails with the following error:

│ Error: updating Step Functions State Machine (arn:aws:states:eu-west-3:000000000000:stateMachine:my-state-machine): InvalidDefinition: Error=ValueError Args=["Expected 2 arguments for function type '<class 'localstack.services.stepfunctions.asl.component.intrinsic.function.statesfunction.string_operations.string_split.StringSplit'>', but got: '(FunctionArgumentList| {'arg_list': [], 'size': 0}'."] in definition '{
│   "StartAt": "GetSuffix",
│   "States": {
│     "GetSuffix": {
│       "Type": "Pass",
│       "Parameters": {
│         "suffix.$": "States.ArrayGetItem(States.StringSplit($$.StateMachine.Name, '-'), States.MathAdd(States.ArrayLength(States.StringSplit($$.StateMachine.Name, '-')), -1))"
│       },
│       "End": true
│     }
│   }
│ }
│ '.
│ 
│   with aws_sfn_state_machine.main,
│   on stepFunction.tf line 1, in resource "aws_sfn_state_machine" "main":
│    1: resource "aws_sfn_state_machine" "main" {

Based on my tests there seems to be 2 issues:

  • Using a variable starting with $$ as a function argument is not supported.
  • Passing the result of a function directly as another function argument is not supported.

Expected Behavior

The definition should be considered valid and the state machine should be created.

How are you starting LocalStack?

With the localstack script

Steps To Reproduce

Create a state machine using the provided definition.

Environment

- LocalStack: 2.3.0
- PROVIDER_OVERRIDE_STEPFUNCTIONS=v2
- Terraform v1.6.2

Anything else?

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions