rko
rko

Reputation: 312

Passing state input into ssm send-command in step function

I have a step function with 7 steps. I pass the input into the step function as a JSON and then access the inputs under $$.Execution.Input.(input name). I want to pass these inputs in a ssm-send command state through a step function. Looks like the step function (RunSSMScript) takes the correct input, however, does not execute the variables in the command correctly. Here's the json of the relevant state machines

    "GetContextData": {
      "Type": "Pass",
      "Parameters": {
        "mode.$": "$$.Execution.Input.mode",
        "algo.$": "$$.Execution.Input.algo"
      },
      "ResultPath": "$.InputContext",
      "Next": "RunSSMScript"
    },
    "RunSSMScript": {
      "Type": "Task",
      "Resource": "arn:aws:states:::aws-sdk:ssm:sendCommand",
      "Parameters": {
        "InstanceIds": [
          "i-xxxxxxxxxxxxxxxx"
        ],
        "DocumentName": "AWS-RunShellScript",
        "Parameters": {
          "commands": [
            "sudo -u ubuntu /bin/bash /home/ubuntu/environment/ibkr/automation/runIb.sh -m $.InputContext.mode -a $.InputContext.algo",
            "sudo kill $(pgrep -f runIb)",
            "sudo kill $(pgrep -f Xvfb)"
          ]
        }
      }

The output of the RunSSMScript shows that the commands array does not take the $.InputContext.mode or the $.InputContext.algo inputs when it tries to execute the runIb.sh file.

The input for the RunSSMScript shows up fine as:

{
  "InputContext": {
    "mode": "paper",
    "algo": "mftaa"
  }
}

Upvotes: -1

Views: 63

Answers (0)

Related Questions