targets = {
my-target = local.target_nodes
coming from locals:
locals {
my_nodes = [
for n in range(5) : templatefile("./templates/my_template.tftpl", {
index = n
})
}
eventuelly being merged in tf module code:
eventbridge_targets = flatten([
for index, rule in var.rules : [
for target in var.targets[index] :
merge(target, {
"rule" = index
"Name" = var.append_rule_postfix ? "${replace(index, "_", "-")}-rule" : index
})
] if length(var.targets) != 0
])
the merge in the module fails with the error:
Call to function "merge" failed: arguments must be maps or objects, got
│ "string".
the module code is not the issue here, (its a often used module terraform-aws-eventbridge/main.tf at 5a935234c6d7c528ed532e4b9ba7122bfe04dfd1 · terraform-aws-modules/terraform-aws-eventbridge · GitHub)
but as you can see i want to give it a generated list of targets
the tftpf contains valid HCL
[{
name = "test${index}"
ecs_target = {
launch_type = "FARGATE"
task_count = 1
task_definition_arn = .................
.......etc
}, { <another target like above} ]
not sure what the proper implementation should be to avoid the error and give a valid structure / object to the module.
Help is appreciated(!)