Any trick to get Step Function inputs into environmental variables of an AWS batch job?
Hi, sorry for the fairly basic question but I'm having a lot of trouble figuring out how to pipe step function inputs into my batch jobs, which are being run on basic alpine linux ECR images. I developed the images so that I can point them at an API via the enviromental variables.
The problem I've been hitting is I cannot figure out how to get the step function inputs into the batch jobs I'm running. All of the various infrastructure is built via terraform, so I need to add the environmental variables when the step function calls the batch jobs and tells them to run.
{
"Comment": "A description of my state machine",
"StartAt": "xxxxxx Job",
"QueryLanguage": "JSONata",
"States": {
"blahblah Job": {
"Type": "Task",
"Resource": "arn:aws:states:::batch:submitJob.sync",
"Arguments": {
"JobName": "blahJob",
"JobDefinition": "job-def-arn:69",
"JobQueue": "job-queue"
},
"Next": "bleg Job",
"Assign": {
"apiCall": "$states.input.apiCall",
"wid": "$states.input.wid"
}
},
"bleg Job": {
"Type": "Task",
"Resource": "arn:aws:states:::batch:submitJob.sync",
"Arguments": {
"JobDefinition": "job-arn:69",
"JobQueue": "job-queue",
"JobName": "blegJob"
},
"End": true,
"Assign": {
"apiCall": "$states.input.apiCall",
"person": "$states.input.person",
"endpoint": "$states.input.endpoint"
}
}
}
}
Here's the state machine I'm working with atm, I've been trying setting it via Assign, also tried passing via Parameters, enviroment, but down to try anything to get this working!
I'm just specifically stumped on how to get the step function inputs into the Batch job when the step function calls them. I'm going to try futzing around with command today to see if I can get them into the environment in the Batch.
Thanks for taking the time to take a look, and let me know if I need to post any more info!
Edit: Figured it out thanks to /u/SubtleDee, had to add this
"ContainerOverrides": {
"Environment": [
{
"Name": "var1",
"Value": "{% $states.input.value1 %}"
},
{
"Name": "var2",
"Value": "{% $states.input.value2 %}"
}
]
}
to my arguments to get the variables into my batch jobs using the state function input values. I appreciate the fast help!