codetheweb / serverless-step-functions-local

Run AWS step functions offline with Serverless
MIT License
17 stars 17 forks source link

Fix for parent-child state machine calls #28

Open nplusterio opened 3 months ago

nplusterio commented 3 months ago

Description

Dependencies

Steps to replicate issue:

  1. Given the following simple serverless.yml example:
    
    service: my-step-functions-local

provider: name: aws runtime: nodejs18.x region: us-east-2

custom: application: MyStepFunctions

stepFunctionsLocal: accountId: 101010101010 region: us-east-2

stepFunctions: stateMachines: childStateMachine: name: child-state-machine definition: Comment: "Child State Machine" StartAt: SayHello States: SayHello: Type: Pass Result: "Hello from Child State Machine" End: true parentStateMachine: name: parent-state-machine definition: Comment: "Parent State Machine" StartAt: ExecuteChildStateMachine States: ExecuteChildStateMachine: Type: Task Resource: "arn:aws:states:::states:startExecution.sync:2" Parameters: StateMachineArn: "arn:aws:states:us-east-2:101010101010:stateMachine:child-state-machine" TimeoutSeconds: 599 End: true

plugins:

  1. Run sls offline start
  2. Execute Child State Machine directly by running aws stepfunctions --endpoint-url http://localhost:8083 start-execution --state-machine-arn arn:aws:states:us-east-2:101010101010:stateMachine:child-state-machine (working ✅)
  3. Execute Parent State Machine (which executes the child state machine as a task) by running aws stepfunctions --endpoint-url http://localhost:8083 start-execution --state-machine-arn arn:aws:states:us-east-2:101010101010:stateMachine:parent-state-machine (not working ❌). Getting this error message:
    arn:aws:states:us-east-2:101010101010:execution:parent-state-machine:bbbdc711-2462-4dcc-b6d9-f242c84dbd2c : {"Type":"TaskFailed","PreviousEventId":4,"TaskFailedEventDetails":{"ResourceType":"states","Resource":"startExecution.sync:2","Error":"StepFunctions-AWSStepFunctionsException","Cause":"The security token included in the request is invalid. (Service: AWSStepFunctions; Status Code: 400; Error Code: UnrecognizedClientException; Request ID: 338d459f-04e2-4f57-89cc-8d9b9364cfa8; Proxy: null)"}}

This PR along with the Dependency PR mentioned above should solve this issue.