I have a terraform project where I'm trying to setup a cloudwatch event rule and target to trigger a new aws batch job submission on a schedule. The issue I'm having is passing a static parameter (ie, a variable representing a command to run) from the cloudwatch event to the batch_target.
In my aws_batch_job_definition I have the following as part of the container_properties:
container_properties = <<CONTAINER_PROPERTIES
{
"command": ["echo", "command", "Ref::inputCommand"],
...etc
}
And my cloudwatch event target tied to the schedule rule looks like this:
resource "aws_cloudwatch_event_target" "test_target" {
rule = aws_cloudwatch_event_rule.every_minute.name
role_arn = aws_iam_role.event_iam_role.arn
arn = aws_batch_job_queue.test_queue.arn
batch_target {
job_definition = aws_batch_job_definition.test.arn
job_name = "job-test"
job_attempts = 2
}
input = "{\"inputCommand\": \"commandToRun\"}" #this line does not work as intended
}
Is there a simple way to use the input or input_transformer properties for the event_target to pass through the variable inputCommand to the batch job?
The setup works when I submit a job with that parameter and value set through the console, or set a default parameter in the job definition, but I'm having trouble doing it via the cloudwatch event in terraform.