skip to Main Content

I have the following aws step function step defined

"Step": {
  "Type": "Task",
  "Resource": "arn:aws:states:::states:startExecution.sync",
  "Parameters": {
    "Name.$": "$.executionName",
    "StateMachineArn": "${arn}",
    "Input.$": "$"
  }
...

I came across this documentation which illustrates how to associate workflow executions

I tried to apply this in the step above, but I keep getting an error:
InvalidDefinition: Invalid State Machine Definition: 'SCHEMA_VALIDATION_FAILED: The value for the field 'Input.$' must be a valid JSONPath or a valid intrinsic function call at ...

"Step": {
  "Type": "Task",
  "Resource": "arn:aws:states:::states:startExecution.sync",
  "Parameters": {
    "Name.$": "$.executionName",
    "StateMachineArn": "${arn}",
    "Input.$": "States.JsonMerge($, {'AWS_STEP_FUNCTIONS_STARTED_BY_EXECUTION_ID': $$.Execution.Id}, false)"
  }
...

not sure what I am doing wrong here

2

Answers


  1. Not sure if the fist $ is meant to be previous input from a step / input that you provide upon executing the sfn, but either way.. You can construct your own json within your Input field like so:

        "Step": {
          "Type": "Task",
          "Resource": "arn:aws:states:::states:startExecution.sync",
          "Parameters": {
            "Name.$": "$.executionName",
            "StateMachineArn": "${arn}",
            "Input": {
                    "PreviousInput.$": "$",
                    "AWS_STEP_FUNCTIONS_STARTED_BY_EXECUTION_ID.$": "$$.Execution.Id"
               }
          }
    
    Login or Signup to reply.
  2. As mentioned by @fedondev – you have to stringify and escape the object literal you are passing in second arg to JsonMerge. So your Input should look like:

    "Input.$": "States.JsonMerge($, States.StringToJson(States.Format('\{"AWS_STEP_FUNCTIONS_STARTED_BY_EXECUTION_ID":"{}"\}', $$.Execution.Id)), false)"
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search