<p>I'm learning how to use the replace function within go templating but I'm running into an issue.</p>
<p>I have my template build this:</p>
<pre><code>  - cpuRequest: 200m
    etcdMembers:
    - instanceGroup: master-us-east-1a
      name: us-east-1a
    - instanceGroup: master-us-east-1d
      name: us-east-1d
    - instanceGroup: master-us-east-1f
      name: us-east-1f
</code></pre>
<p>and I want it to build this:</p>
<pre><code>  - cpuRequest: 200m
    etcdMembers:
    - instanceGroup: master-us-east-1a
      name: a
    - instanceGroup: master-us-east-1d
      name: d
    - instanceGroup: master-us-east-1f
      name: f
</code></pre>
<p>I'm currently using this function:</p>
<pre><code>  {{ range $i, $az := .availability_zones }}
    - instanceGroup: master-{{ . }}
      name: {{  . | replace $.region &quot;&quot; }} {{/* converts us-east-1a to a */}}
  {{ end }}
</code></pre>
<p>Unfortunately what I'm doing is not converting us-east-1a to just a. Any thoughts?</p>

TravelingLex
<p>I figured out that the region value was not being filled causing the replace function to not act appropriately..</p>
