<p>I'm using 0.14.2 Terraform version and 1.3.2 Helm provider.</p>
<p>I have a terraform task where I get an output and then I use in a helm chart. So far so good.
In the task where I execute de helm deploy I set the var I have to use:</p>
<pre><code>resource &quot;helm_release&quot; &quot;kong-deploy&quot; {
  for_each   =  local.ob

  chart      = &quot;./helm-charts/kong&quot;
  name       = &quot;kong&quot;
  namespace  = each.value
  create_namespace = true
  version    = &quot;platform-2.10&quot;
  timeout = 30
  values = [file(&quot;./helm-values/${local.environment}/kong/kong-${local.environment}-${each.value}.yaml&quot;)]
   set {
      name  = &quot;WORKER_NODE&quot;
      value = aws_eks_node_group.managed_workers[each.value].node_group_name
      type  = &quot;string&quot;
    }
}
</code></pre>
<p>The tree directory is like that and I have to use the WORKER_NODE var in the postgres subchart.</p>
<pre><code>├── charts
│   └── postgres
│       ├── Chart.yaml
│       ├── templates
│       │   ├── deployment.yaml
│       │   ├── env.yaml
│       │   └── service.yaml
│       └── values.yaml
├── Chart.yaml
├── files
│   └── purgeKongService.sh
├── templates
│   ├── configmap.yaml
│   ├── deployment.yaml
│   ├── env.yaml
│   ├── ingress.yaml
│   └── service.yaml
└── values.yaml
</code></pre>
<p>I tried to use this var like the other charts, but with no success:</p>
<pre><code>nodeSelector:
        eks.amazonaws.com/nodegroup: &quot;{{ .Values.WORKER_NODE }}&quot;
</code></pre>
<p>HOw can I pass this var to a subchart?</p>

hmar
<p>If I'm understanding this right, you want to access the parent chart value's inside the subchart. To do that you can set it as a global value or define the subchart values separately. In this case I would set it as a global value:</p>
<p><code>values.yaml</code>:</p>
<pre><code>    global:
      WORKER_NODE: &lt;default value&gt;
</code></pre>
<p>From there, in your TF code you can set it via <code>global.WORKER_NODE</code> to pass to both <code>kong</code> chart and the <code>postgres</code> subchart.</p>
<p>Also, it's best practice to use camelCase when naming chart values. So instead of <code>WORKER_NODE</code>, you should do <code>workerNode</code>.</p>
<p>Best Practices: <a href="https://helm.sh/docs/chart_best_practices/values/" rel="nofollow noreferrer">https://helm.sh/docs/chart_best_practices/values/</a></p>
<p>Subcharts and Globals: <a href="https://helm.sh/docs/chart_template_guide/subcharts_and_globals/#global-chart-values" rel="nofollow noreferrer">https://helm.sh/docs/chart_template_guide/subcharts_and_globals/#global-chart-values</a></p>
