<p>using 0.13.2 Helm provider terraform, I have a Chart with a subchart nested:</p>
<pre><code>├── charts
│   └── postgres
│       ├── Chart.yaml
│       ├── templates
│       │   ├── deployment.yaml
│       │   ├── env.yaml
│       │   └── service.yaml
│       └── values.yaml
├── Chart.yaml
├── templates
│   ├── configmap.yaml
│   ├── deployment.yaml
│   ├── env.yaml
│   ├── ingress.yaml
│   └── service.yaml
└── values.yaml
</code></pre>
<p>I need to use from the deployment.yml of the postgres subchart, the values of the parent chart. How can I config the configmap of the subchart to get the parent chart values? My current configmap is like this:</p>
<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ .Release.Name }}-postgres-env
  namespace: {{ .Release.Namespace }}
data:
  {{- range $key, $val := .Values.environment }}
  {{ $key }}: {{ $val | quote }}
  {{- end }}
</code></pre>
<p>Thanks in advance.</p>

<p>You can't directly do this.  In discussing <a href="https://docs.helm.sh/docs/topics/charts/#scope-dependencies-and-values" rel="nofollow noreferrer">Scope, Dependencies, and Values</a>, the Helm documentation notes (with a motivating example):</p>
<blockquote>
<p>Charts at a higher level have access to all of the variables defined beneath. So the WordPress chart can access [<code>.Values.child.setting</code>]. But lower level charts cannot access things in parent charts, so [the child] will not be able to access [a parent] property. Nor, for that matter, can it access [sibling subchart settings].</p>
</blockquote>
<p>You have two options.  If you move the settings under a <code>global:</code> key</p>
<pre class="lang-yaml prettyprint-override"><code>global:
  environment:
    keys: values
</code></pre>
<p>then the parent and <em>all</em> subcharts will be able to access <code>.Values.global.environment</code>.  Or, if you move the settings under a key specific to the subchart</p>
<pre class="lang-yaml prettyprint-override"><code>postgres:
  environment:
    keys: values
</code></pre>
<p>then the subchart will see <code>.Values.environment</code>, and the parent can reference <code>.Values.postgres.environment</code>.</p>
<p>(If you can't use a prepackaged PostgreSQL chart, it's not necessarily wrong to flatten these parts into a single chart, making it clear from the filenames that something is <code>statefulset-postgres.yml</code> or <code>svc-postgres.yml</code>.  Then the templates would be able to use the single <code>.Values</code>.)</p>
