Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Cloudwatch (EventBridge) Event Rule for AWS Batch with Environment Variables

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"
    }
}
like image 438
P Walker Avatar asked Oct 16 '25 17:10

P Walker


1 Answers

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"
    }
}
like image 137
P Walker Avatar answered Oct 18 '25 07:10

P Walker



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!