在 terraform 的 azure data explorer 中使用 eventhub 的默认消费者组

using default consumer group of eventhub in azure data explorer in terraform

我可以使用 $Default 消费者组连接 azure 仪表板中的 azure data explorer 集群。但是当我尝试从 terraform 执行相同操作时,出现错误。

获取默认消费组数据

data "azurerm_eventhub_consumer_group" "default" {
  name                = "$Default"
  namespace_name      = azurerm_eventhub_namespace.eh_namespace.name
  eventhub_name       = azurerm_eventhub.eh.name
  resource_group_name = var.resource_group
}

尝试在 adx 中使用

resource "azurerm_kusto_eventhub_data_connection" "eventhub_connection" {
  name                = var.adx_eh_connection_name
  resource_group_name = var.resource_group
  location            = data.azurerm_resource_group.eh_adx.location
  cluster_name        = azurerm_kusto_cluster.adx.name
  database_name       = azurerm_kusto_database.database.name

  eventhub_id    = azurerm_eventhub.eh.id
  consumer_group = data.azurerm_eventhub_consumer_group.default.name

  table_name        = var.adx_db_table_name
  mapping_rule_name = var.ingestion_mapping_rule_name
  data_format       = var.eh_message_format
}

获取错误

Error: invalid value for consumer_group (The consumer group name can contain only letters,
numbers, periods (.), hyphens (-),and underscores (_), up to 50 characters, and 
it must begin and end with a letter or number.)
  on adx.tf line 25, in resource "azurerm_kusto_eventhub_data_connection" "eventhub_connection":
  25: resource "azurerm_kusto_eventhub_data_connection" "eventhub_connection" {

版本

此问题之前已在 Github issue 中报告过,但已在 azurerm provider version 2.28.0 中解决。对于解决方案,请使用 最新的 terraform 版本和 azurerm 版本

我用 Terraform 版本 1.0.11 和最新的 azurerm 提供程序进行了相同的测试,即2.88.1.

data "azurerm_eventhub_consumer_group" "consumer_group" {
  name                = "$Default"
  namespace_name      = azurerm_eventhub_namespace.eventhub_ns.name
  eventhub_name       = azurerm_eventhub.eventhub.name
  resource_group_name = azurerm_resource_group.rg.name
}

resource "azurerm_kusto_eventhub_data_connection" "eventhub_connection" {
  name                = "my-kusto-eventhub-data-connection"
  resource_group_name = azurerm_resource_group.rg.name
  location            = azurerm_resource_group.rg.location
  cluster_name        = azurerm_kusto_cluster.cluster.name
  database_name       = azurerm_kusto_database.database.name

  eventhub_id    = azurerm_eventhub.eventhub.id
  consumer_group = data.azurerm_eventhub_consumer_group.consumer_group.name
}

输出: