2

I have a batch Job with a single Job Definition that executes depending on a parameter on the environment command option.

The original value is "--param2=XXX" but I need this to be dynamic according to the Input parameters of the Step Functions.

{
  "param2": "--param2=YYY"
}

I haven't been able to replace the value in the Step Function with the Input Value

{
    "Step1": {
        "Type": "Task",
        "Resource": "arn:aws:states:::batch:submitJob.sync",
        "Parameters": {
            "JobDefinition": "arn:aws:batch:us-east-2:zzzzzzzzz:job-definition/XXXXXX",
            "JobQueue": "arn:aws:batch:us-east-2:zzzzzzzz:job-queue/YYYYYY",
            "JobName": "Step1",
            "ContainerOverrides": {
                "Environment": [
                    {
                        "Name": "envparam",
                        "Value": "0"
                    }
                ],
                "Command": [
                    "python",
                    "run.py",
                    "--param=val",
                    "$.param2"
                ]
            }
        },
        "Next": "Step2"
    }
}
Rednaxel
  • 938
  • 2
  • 16
  • 33

1 Answers1

1

I found a solution adding a Parameter to Batch and it is referenced using Ref::Param2

This is the complete code

{
    "Step1": {
        "Type": "Task",
        "Resource": "arn:aws:states:::batch:submitJob.sync",
        "Parameters": {
            "JobDefinition": "arn:aws:batch:us-east-2:zzzzzzzzz:job-definition/XXXXXX",
            "JobQueue": "arn:aws:batch:us-east-2:zzzzzzzz:job-queue/YYYYYY",
            "JobName": "Step1",
            "Parameters": {
                "Param2.$": "$.param2"
            },
            "ContainerOverrides": {
                "Environment": [
                    {
                        "Name": "envparam",
                        "Value": "0"
                    }
                ],
                "Command": [
                    "python",
                    "run.py",
                    "--param=val",
                    "Ref::Param2"
                ]
            }
        },
        "Next": "Step2"
    }
}
Rednaxel
  • 938
  • 2
  • 16
  • 33