title: Terraform - join/Concatanate variables with string
body: <p>variables.tf</p>
  
  <pre><code>variable "env_name" {
    default = "some_client"
  }
  
  variable "azure_instance_names" {
    default = [
      "AD01",
      "AD01",
    ]
  }
  </code></pre>
  
  <p>I', trying to create Public IP for as many instances as specified in <code>azure_instance_names</code> variable (2 in this case), i have issues with naming this resource, i want to create name by joining <code>env_name</code> and <code>azure_instance_names</code> variable. It must be one word, separated by <code>-</code>, so name should be in env_name-azure_instance_names for example:</p>
  
  <p><strong>Desired output</strong></p>
  
  <p>name=<code>some_client-AD01
        some_client-AD02</code></p>
  
  <p><strong>Actual output:</strong></p>
  
  <p>name=<code>some_client AD01
        some_client AD02</code></p>
  
  <p>main.tf</p>
  
  <pre><code>resource "azurerm_public_ip" "datasourceip" {    
    count               = "${length(var.azure_instance_names)}"
    name                = "${join("-", list(format("%s %s", var.env_name, element(var.azure_instance_names, count.index))))}"
    location            = "${azurerm_resource_group.res_group.location}"
    resource_group_name = "${azurerm_resource_group.res_group.name}"
    allocation_method   = "Static"
  }
  </code></pre>
  
  <p>In terraform apply i'm getting:</p>
  
  <pre><code>+ azurerm_public_ip.datasourceip[1]
        id:                      &lt;computed&gt;
        allocation_method:       "Static"
        fqdn:                    &lt;computed&gt;
        idle_timeout_in_minutes: "4"
        ip_address:              &lt;computed&gt;
        ip_version:              "IPv4"
        location:                "westeurope"
        name:                    "some_client AD01"
        resource_group_name:     "myrg1"
        sku:                     "Basic"
        tags.%:                  &lt;computed&gt;
  </code></pre>
  
  <p>Because Azure doesn't accept resource name in more than one word i', trying to join "-" to <code>var.env_name,  var.azure_instance_names</code> so resource name should be <code>some_client-AD01</code></p>
  
  <p>Although i specified join function i', still getting same error:</p>
  
  <blockquote>
    <p>azurerm_public_ip.datasourceip.1: Error Creating/Updating Public IP "some_client AD01" (Resource Group "myrg1"): network.PublicIPAddressesClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="InvalidResourceName" Message="Resource name some_client LBA-P-EU2B-AD01 is invalid. The name can be up to 80 characters long. It must begin with a word character, and it must end with a word character or with '<em>'. The name may contain word characters or '.', '-', '</em>'." Details=[]</p>
  </blockquote>