PSKP
PSKP

Reputation: 1375

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

I can use $Default consumer group in connection azure data explorer cluster from the azure dashboard. but when I tried to do the same from the terraform, I am getting error.

Getting data of default consumer group

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
}

Tried to use in 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
}

Getting error

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" {

Versions

Upvotes: 1

Views: 910

Answers (1)

Ansuman Bal
Ansuman Bal

Reputation: 11451

The issue was reported before in this Github issue but it has been resolved in azurerm provider version 2.28.0. For solution please use latest terraform version and azurerm version.

I tested the same with Terraform version 1.0.11 and latest azurerm provider i.e. 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
}

Output:

enter image description here

Upvotes: 3

Related Questions