<p>I'm using 0.14.7 terraform version and 1.3.2 Helm provider.</p>
<p>I'm trying to deploy the same chart application with different values file and different namespace like totally independent applications:</p>
<pre><code>resource &quot;helm_release&quot; &quot;kong-deploy&quot; {
  for_each   =  var.country

  chart      = &quot;./helm-charts/kong&quot;
  name       = &quot;kong&quot;
  namespace  = &quot;each.value.country&quot;
  create_namespace = true
  version    = &quot;2.0&quot;
  timeout = 60
  values = [
    file(&quot;./helm-values/${local.environment}/kong-${local.environment}-${each.value.country}.yaml&quot;)
  ]
}
</code></pre>
<p>And here are the tfvars:</p>
<pre><code>country = {
    spain = &quot;es&quot;
    united_kingdom = &quot;uk&quot;
}
</code></pre>
<p>The expected result is that helm-release use the <code>kong-pre-es/uk.yml</code> file.</p>
<p>But whe I'm doing the terraform plan, I'm getting the next error:</p>
<pre><code>Error: Unsupported attribute

  on deploy.tf line 11, in resource &quot;helm_release&quot; &quot;kong-deploy&quot;:
  11:     file(&quot;./helm-values/${local.environment}/kong-${local.environment}-${each.value.country}.yaml&quot;)
    |----------------
    | each.value is &quot;es&quot;

This value does not have any attributes.


Error: Unsupported attribute

  on deploy.tf line 11, in resource &quot;helm_release&quot; &quot;kong-deploy&quot;:
  11:     file(&quot;./helm-values/${local.environment}/kong-${local.environment}-${each.value.country}.yaml&quot;)
    |----------------
    | each.value is &quot;uk&quot;

</code></pre>
<p>I don't know where is the error.. Could you help me?</p>
<p>Thanks</p>

hmar
<p>In this example, you are iterating over a Map with key-value pairs <code>&quot;spain&quot; = &quot;es&quot;, &quot;united_kingdom&quot; = &quot;uk&quot;</code>. In your scope, the temporary lambda iterator variable <code>each.key</code> is assigned the current iterator's key for Map iteration, and <code>each.value</code> is assigned the current iterator's value for Map iteration.</p>
<p>For example, in the first iteration, <code>each.key</code> would be assigned <code>spain</code>, and <code>each.value</code> would be assigned <code>es</code>.</p>
<p>Assuming that you want the country name in <code>each.value.country</code>, then this is the key in your Map, and you would update like:</p>
<pre><code>values = [file(&quot;./helm-values/${local.environment}/kong-${local.environment}-${each.key}.yaml&quot;)]
</code></pre>
<p>and that will resolve to a suffix of <code>spain.yml</code> in the first iteration.</p>
<p>If instead you want the language name, then this is the value in your Map, and you would update like:</p>
<pre><code>values = [file(&quot;./helm-values/${local.environment}/kong-${local.environment}-${each.value}.yaml&quot;)]
</code></pre>
