<p>I have a list of properties defined in <code>values.yaml</code> as follows:</p>
<pre><code>files:
 - &quot;file1&quot;
 - &quot;file2&quot;
</code></pre>
<p>Then in my template I want to create config maps out of my values.</p>
<p>I came up with the following template:</p>
<pre><code>{{- range $value := .Values.files }}
---
apiVersion: v1
kind: ConfigMap
metadata: 
    name: {{ $value }}
data:
    {{ $value }}: {{ .Files.Get (printf &quot;%s/%s&quot; &quot;files&quot; $value) | indent 4 }}
{{- end }}
</code></pre>
<p>As you can see I want to have configmaps with same name as files. I mixed up several parts of documentation, however my template does not work as expected.</p>
<p>How can I achieve configmap creation through templates?</p>
<p><strong>//EDIT</strong>
I expect to have the following ConfigMap:</p>
<pre><code>apiVersion: v1
kind: ConfigMap
metadata: 
    name: file1
data:
    file1: &lt;file1 content&gt;
---
apiVersion: v1
kind: ConfigMap
metadata: 
    name: file2
data:
    file2: &lt;file2 content&gt;
</code></pre>

Forin
<p>Try the following:</p>
<pre><code>{{- $files := .Files }}
{{- range $value := .Values.files }}
---
apiVersion: v1
kind: ConfigMap
metadata: 
  name: {{ $value }}
  data:
    {{ $value }}: |
{{ $files.Get (printf &quot;%s/%s&quot; &quot;files&quot; $value) | indent 6 }}
{{- end }}
</code></pre>
<p>You problem seems to be with incorrect indentation. Make sure the line with <code>$files.Get</code> starts with no spaces.</p>
<p>And I also added <code>{{- $files := .Files }}</code> to access <code>.Files</code>, because for some reason <code>range</code> is changeing the <code>.</code> scope.</p>
<p>I have found <a href="https://helm.sh/docs/chart_template_guide/accessing_files/#basic-example" rel="nofollow noreferrer">this example</a> in documentation but it seems to work only if file's content are one-line. So if your files are one line only, then you should check the example.</p>
<p>Also notice the <code>|</code> after <code>{{ $value }}:</code>. You need it because file content is a multiline string. Check <a href="https://stackoverflow.com/questions/3790454/how-do-i-break-a-string-over-multiple-lines">this StackQuestion</a> on how to use multiline strings in yaml.</p>
