I'm learning how to use the replace function within go templating but I'm running into an issue.
I have my template build this:
- 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
and I want it to build this:
- cpuRequest: 200m
etcdMembers:
- instanceGroup: master-us-east-1a
name: a
- instanceGroup: master-us-east-1d
name: d
- instanceGroup: master-us-east-1f
name: f
I'm currently using this function:
{{ range $i, $az := .availability_zones }}
- instanceGroup: master-{{ . }}
name: {{ . | replace $.region "" }} {{/* converts us-east-1a to a */}}
{{ end }}
Unfortunately what I'm doing is not converting us-east-1a to just a. Any thoughts?
I figured out that the region value was not being filled causing the replace function to not act appropriately..