title: Splitting a comma separated string
body: <p>I have an output that is a multi-valued, comma separated string.</p>
  
  <h3>input.tf</h3>
  
  <pre><code>resource "azurerm_app_service" "testap" {
    name                = "MySuperCoolAppServer001"
    location            = "eastus"
    resource_group_name = "notshown"
    app_service_plan_id = "notshown"
  }
  </code></pre>
  
  <h3>output.tf</h3>
  
  <pre><code>output "output_tf_testap_outbound_ip_addresses" {
    value = "${azurerm_app_service.testap.outbound_ip_addresses}"
  }
  </code></pre>
  
  <p>And I get this in the console:</p>
  
  <blockquote>
    <p>output_tf_testap_outbound_ip_addresses =
    1.2.3.4,1.2.3.5,1.2.3.6,1.2.3.7,1.2.3.8,1.2.3.9</p>
  </blockquote>
  
  <p>How do I get the first item of the list?  In this case, I'm trying to isolate the value:</p>
  
  <blockquote>
    <p>1.2.3.4</p>
  </blockquote>
  
  <p>Is there a way to get a "collection" of all the items when the total number of items is not known before run time? (The list above has 6 items).</p>
  
  <p>The following code doesn't seem to work:</p>
  
  <pre><code>output "first_ip" {
    value = ["${azurerm_app_service.testap.outbound_ip_addresses[0]}"]
  }
  </code></pre>
  
  <p>===================== APPEND =================</p>
  
  <p>first_ip_no_index works.  first_ip does not</p>
  
  <pre><code>output "first_ip_no_index" {
    value = ["${split(",", azurerm_app_service.tf_middle_tier_azurerm_app_service.outbound_ip_addresses)}"]
  }
  
  output "first_ip" {
    value = "${split(",", azurerm_app_service.tf_middle_tier_azurerm_app_service.outbound_ip_addresses)[0]}"
  }
  </code></pre>
  
  <p>first_ip  generated this error:</p>
  
  <blockquote>
    <p>Error reading config for output first_ip: parse error at 1:91:
    expected "}" but found "["</p>
  </blockquote>