<p>I wish to create Persistent Volumes across multiple zones.</p>
<p>There are two lists inside the data object, one for az's and the other for vol id's.</p>
<p>The structure is:</p>
<pre><code>persistentVolume:
  az:
  - eu-west-2a
  - eu-west-2b
  - eu-west-2c
  storageClassName: postgres
  storage: 10Gi
  accessModes: ReadWriteOnce
  volumeID:
  - vol-123
  - vol-456
  - vol-789
  fsType: ext4
</code></pre>
<p>The Helm config:</p>
<pre><code>{{- $fullName := include &quot;postgres.fullname&quot; $ -}}
{{- range .Values.persistentVolume }}
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: {{ $fullName }}
  labels:
    type: {{ $fullName  }}
    az: {{ .az }}
spec:
  storageClassName: {{ .Values.persistentVolume.storageClassName }}
  capacity:
    storage: {{ .Values.persistentVolume.storage }}
  accessModes:
  - {{ .Values.persistentVolume.accessModes }}
  awsElasticBlockStore:
    volumeID: {{ .volumeID }}
    fsType: {{ .Values.persistentVolume.fsType }}
{{- end }}
</code></pre>
<p>But this error with:</p>
<pre><code>template: postgres/templates/pv.yaml:10:11: executing &quot;postgres/templates/pv.yaml&quot; at &lt;.az&gt;: can't evaluate field az in type interface {}
</code></pre>
<p>Any tips or pointers would be much appreciated :-)</p>

<p>It is not possible to do what you want with the current structure you have, but if you are willing to change your <code>values.yaml</code> a bit:</p>
<pre><code>persistentVolume:
  az:
    - region: eu-west-2a
      volumeID: vol-123
    - region: eu-west-2b
      volumeID: vol-456
    - region: eu-west-2c
      volumeID: vol-789
  storageClassName: postgres
  storage: 10Gi
  accessModes: ReadWriteOnce
  fsType: ext4
</code></pre>
<p>then you could do (simplified example, but I am sure you will get the idea):</p>
<pre><code>{{- $storageClassName := .Values.persistentVolume.storageClassName }}
{{- $volumes := .Values.persistentVolume }}
{{- range $volumes.az }}
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: test
  labels:
    type: test
    az: {{ .region }}
spec:
  storageClassName: {{ $storageClassName }}
  awsElasticBlockStore:
    volumeID: {{ .volumeID }}
{{- end }}
</code></pre>
<p>Note the <code>{{- $storageClassName := .Values.persistentVolume.storageClassName }}</code>. You need to do this because <code>helm</code> has the notion of &quot;scope&quot;, which you can read a lot more in the docs.</p>
