Hello
I hope someone can help me with this one i cant figure out how to do it:
I have my data that look like this
sa_list = {
"app_1-test" = {
"consumers" = [
"topic-1",
"topic-2",
"topic-3",
]
"groupId" = "app_1-group"
"name" = "app_1"
}
"app_2-test" = {
"consumers" = [
"topic-1",
"topic-2",
"topic-3",
]
"groupId" = "app_2-group"
"name" = "app_2"
}
}
I can also manage to have my data lookin like this
test = {
"app_1-test" = {
"consumers" = {
"0" = "topic-1"
"1" = "topic-2"
"2" = "topic-3"
}
"groupId" = "app_1-group"
"name" = "app_1"
}
"app_2-test" = {
"consumers" = {
"0" = "topic-1"
"1" = "topic-2"
"2" = "topic-3"
}
"groupId" = "app_2-group"
"name" = "app_2"
}
}
I want to iterate with a for_each to create a resource
resource "confluent_kafka_acl" "aws-app-consumer-read-on-topic" {
for_each = var.sa_list
kafka_cluster {
id = confluent_kafka_cluster.clusters["aws"].id
}
resource_type = "TOPIC"
resource_name = confluent_kafka_topic.topics_aws[each.value.consumers].topic_name
pattern_type = "LITERAL"
principal = "User:${confluent_service_account.aws-app-consumer[each.key].id}"
host = "*"
operation = "READ"
permission = "ALLOW"
rest_endpoint = confluent_kafka_cluster.clusters["aws"].rest_endpoint
credentials {
key = confluent_api_key.cluster-api-key["aws"].id
secret = confluent_api_key.cluster-api-key["aws"].secret
}
}
But i end up with this fail
each.value.consumers is tuple with 3 elements
I know it’s not possible but i’m trying to do something like this in my resource:
for_each = var.sa_list
count = count(each.value.consumers)
...
resource_name = confluent_kafka_topic.topics_aws[each.value.consumers[count.index].topic_name