3

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"
    }
}

1 Answer 1

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"
    }
}
Sign up to request clarification or add additional context in comments.

1 Comment

Do you know of any way to do this with just Step Functions? Parameters isn't available for Step Functions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.