I am working with an eventbridge rule that runs daily and triggers an ECS task definition as the eventbridge target (cloudwatch-event target). In my terraform script, I'm trying to pass a parameter using eventbridge input variable to the task definition.
This is what I currently have:
resource "aws_cloudwatch_event_target" "target" {
rule = var.rule_name
target_id = var.target_id
arn = var.target_arn
role_arn = var.role_arn
input = jsonencode(
{
start : "10h15",
end : "12h"
})
}
output "eventbridge_inputs" {
value = module.event-bridge.*.input
}
Then in my task-definition, I'm trying to do something like this:
module "ecs_task_definition" {
source = "../../"
name = "var.name
...
task_container_command = ["python", "-m", "app", lookup(module.event-bridge.eventbridge_inputs, "start", "10h"), lookup(module.event-bridge.eventbridge_inputs, "end", "12h")]
I'm running into some type errors because of the lookup but I'm pretty sure it's not the most elegant way to do this. I dont think input_transformer is a good option for me here because I'm not receive these parameters, I really want to provide them to ecs using eventbridge. I found some relevant solutions about it in python but nothing related to terraform Any ideas?