Event Hub disaster recovery alias connection is not set when running deployment for the first time

Hi,

I am trying to deploy Event Hub with Namespace.

Here is what I have done

Deploy Primary Namespace
Then Secondary Namespace
Then Disaster Recovery Config
Output alias connection string using Primary Namespace

I am trying to output azurerm_eventhub_namespace.primaryNamespace.default_primary_connection_string_alias

However, this outputs “”… An empty string

I checked the state file and noticed that default_primary_connection_string_alias is ""

if I run terraform apply again then all of this works fine, and alias connection string is returned correctly (Probably because it does a refresh for all states at the beginning.

so, it seems to me when I first create the primary namespace this state is set and not updated when disaster recovery config has completed.

I tried to google if there is anything that can be added after DR completes and before output to refresh the state of primary namespace.
or if there is even anything like ListKeys for terraform like there is for ARM, but no luck.

If anybody knows a fix/workaround for this (except running terraform apply again) or if I am doing something wrong, please let me know.

Figure out how to do this…

Include

data "azurerm_eventhub_namespace" "primaryNamespace" {

    resource_group_name = azurerm_eventhub_namespace.primaryNamespace.resource_group_name

    name                 = azurerm_eventhub_namespace.primaryNamespace.name

  depends_on = [

    azurerm_eventhub_namespace_disaster_recovery_config.namespaceDisasterRecovery

  ]

}

Use this to get the default_primary_connection_string_alias

data.azurerm_eventhub_namespace.primaryNamespace.default_primary_connection_string_alias