0

I have question around azurerm eventhub. Right now I am data referring to Eventhub namespace but I am unable to get the instances in the output!

data "azurerm_eventhub_namespace" "eventhub_namespace" {
  name  ="example"
  resource_group_name = "example resource group"
}

but do we have something like

data "azurerm_eventhub_instance" "eventhub_instace" {
  name_instance  ="example"
  resource_group_name = "example resource group"
}
halfer
  • 19,824
  • 17
  • 99
  • 186

2 Answers2

2

Unfortunately, I'm afraid you cannot do that. Terraform only expose azurerm_eventhub_instance in the data source. So what you want does not support by Terraform.

The possible solution is that you can use the external data source to execute the script, and then use the script to get the instance in the namespace.

Charles Xu
  • 29,862
  • 2
  • 22
  • 39
0

I came up with these small script to grab con string's.

#!/usr/bin/env bash
RG=$1
EVENTHUBNAMESPACE=$2
SUBSCRIPTION=$3
az eventhubs eventhub list --resource-group "$RG" --namespace-name "$EVENTHUBNAMESPACE" --subscription "$SUBSCRIPTION" > eventhub.json
eventhub=( $(jq -r '.[].name' eventhub.json) )
for eventhub in "${eventhub[@]}"; do
 az eventhubs eventhub authorization-rule keys list --resource-group "$RG"  --namespace-name "$EVENTHUBNAMESPACE" --eventhub-name "$eventhub" --name "$eventhub" --subscription "$SUBSCRIPTION" > eventhubcon.json
 arr=( $(jq -r '.primaryConnectionString' eventhubcon.json) )
  for constr in "${arr[@]}"; do
  printf '%s\n' "${arr[@]}"
  done
done

  • 1
    This is not the answer to the question you asked, although it's another direction of the solution. I think my answer answered your question correctly. – Charles Xu Feb 05 '20 at 01:34