Reputation: 592
I have created a Cloudwatch Event (EventBridge) Rule that triggers an AWS Batch Job and I want to specify an environment variable and parameters. I'm trying to do so with the following Configured Input (Constant [JSON text]), but when the job is submitted, then environment variables I'm trying to setup in the job with are not included and the parameters are the defaults. The parameters are working as expected.
{
"ContainerProperties": {
"Environment": [
{
"Name": "MY_ENV_VAR",
"Value": "MyVal"
}
]
},
"Parameters": {
"one": "1",
"two": "2",
"three": "3"
}
}
Upvotes: 4
Views: 2858
Reputation: 22553
The preceding solution DIDN'T work for me. The correct answer can be found here:
https://aws.amazon.com/premiumsupport/knowledge-center/batch-parameters-trigger-cloudwatch/
I was only able to pass parameters to the job like so:
{
"Parameters": {
"customers": "tgc,localhost"
}
}
I wasn't able to get environment variables to work and didn't try ContainerOverrides.
Upvotes: 0
Reputation: 592
As I was typing out the question, I actually thought to look at the Submit Job API to see what I was doing wrong (I was referencing the CFTs for the Job Definition as my thought process above). For others it may help, I found that I needed to use ContainerOverrides
rather than ContainerProperties
to have it work properly.
{
"ContainerOverrides": {
"Environment": [
{
"Name": "MY_ENV_VAR",
"Value": "NorthAmerica"
}
]
},
"Parameters": {
"one": "1",
"two": "2",
"three": "3"
}
}
Upvotes: 10