I added a piece of code to support enable/disable to the feature - I used the count. Now I have the following problem:
ERROR:
on modules/eventhub/main.tf line 110, in resource "azurerm_eventhub" "events":
110: namespace_name = azurerm_eventhub_namespace.eventhub.*.name
|----------------
| azurerm_eventhub_namespace.eventhub is tuple with 1 element
Inappropriate value for attribute "namespace_name": string required.
Create EventHub namespace
resource "azurerm_eventhub_namespace" "eventhub" {
count = var.enable_eh ? 1 : 0
name = "${var.name}-ns"
location = var.location
resource_group_name = var.resource_group
sku = var.sku
capacity = var.capacity
dedicated_cluster_id = azurerm_eventhub_cluster.eventhub[count.index].id #for eventHub Cluster
auto_inflate_enabled = var.auto_inflate != null ? var.auto_inflate.enabled : null
maximum_throughput_units = var.auto_inflate != null ? var.auto_inflate.maximum_throughput_units : null
dynamic "network_rulesets" {
for_each = var.network_rules != null ? ["true"] : []
content {
default_action = "Deny"
dynamic "ip_rule" {
for_each = var.network_rules.ip_rules
iterator = iprule
content {
ip_mask = iprule.value
}
}
dynamic "virtual_network_rule" {
for_each = var.network_rules.subnet_ids
iterator = subnet
content {
subnet_id = subnet.value
}
}
}
}
tags = var.tags
}
resource "azurerm_eventhub_namespace_authorization_rule" "events" {
for_each = local.authorization_rules
name = each.key
namespace_name = azurerm_eventhub_namespace.eventhub.*.name
resource_group_name = var.resource_group
listen = each.value.listen
send = each.value.send
manage = each.value.manage
}
resource "azurerm_eventhub" "events" {
for_each = local.hubs
name = each.key
namespace_name = azurerm_eventhub_namespace.eventhub.*.name <------ problematic line
resource_group_name = var.resource_group
partition_count = each.value.partitions
message_retention = each.value.message_retention
}
I don't know what the issue is.