Terraform - breaking down complex interpolations into steps
If you're like me, and find it arduous to read long strings of characters without getting a headache, you can break down nested Terraform interpolations like this:
locals {
connection_string = "${join("", azurerm_eventhub_namespace.eventhub-ns.*.default_primary_connection_string)}"
connection_string_array = "${split(";", local.connection_string)}"
endpoint_def = "${element(local.connection_string_array,0)}"
endpoint_array = "${split("=",local.endpoint_def)}"
endpoint = "${element(local.endpoint_array, 1)}"
}
Now you can go ahead and use ${local.endpoint} in your terraform module in the usual manner.