<p>I'm trying to pass toleration values into helm using terraform. But I have got different error messages.</p>
<p>Default values of the <a href="https://artifacthub.io/packages/helm/victoriametrics/victoria-metrics-cluster?modal=values&amp;path=vmstorage.tolerations" rel="nofollow noreferrer">chart are here</a>.</p>
<pre class="lang-yaml prettyprint-override"><code>...
  tolerations:
    []
...
</code></pre>
<p>I use this code.</p>
<pre><code>locals {
  victoria_tolerations = [{ &quot;key&quot; : &quot;k8s-app&quot;, &quot;operator&quot; : &quot;Equal&quot;, &quot;value&quot; : &quot;grafana&quot;, &quot;effect&quot; : &quot;NoSchedule&quot; }]
}


resource &quot;helm_release&quot; &quot;victoria_metrics&quot; {
  name        = var.vm_release_name
  chart       = var.vm_chart
  repository  = var.vm_chart_repository_url
  version     = var.vm_chart_version
  namespace   = local.namespace_victoria
  max_history = var.max_history

set {
    name  = &quot;vmselect.tolerations&quot;
    value = jsonencode(local.victoria_tolerations)
  }
}
</code></pre>
<p>And have got the error message:</p>
<pre><code>Error: failed parsing key &quot;vmselect.tolerations&quot; with value [{&quot;effect&quot;:&quot;NoSchedule&quot;,&quot;key&quot;:&quot;k8s-app&quot;,&quot;operator&quot;:&quot;Equal&quot;,&quot;value&quot;:&quot;grafana&quot;}], key &quot;\&quot;key\&quot;:\&quot;k8s-app\&quot;&quot; has no value (cannot end with ,)
</code></pre>
<p>If I use this variable</p>
<pre><code>victoria_tolerations = &lt;&lt;EOF
      - key: k8s-app
        operator: Equal
        value: grafana
        effect: NoSchedule
    EOF
</code></pre>
<p>I have got this error:</p>
<pre><code>Error: unable to build kubernetes objects from release manifest: error validating &quot;&quot;: error validating data: ValidationError(Deployment.spec.template.spec.tolerations): invalid type for io.k8s.api.core.v1.PodSpec.tolerations: got &quot;string&quot;, expected &quot;array&quot;
</code></pre>
<p>P.S.
Also, I tried to pass as <code>values</code>. This doesn't work in this case.</p>
<pre><code>locals {
  victoria_values = {
    &quot;tolerations&quot; : [
      {
        &quot;key&quot; : &quot;k8s-app&quot;,
        &quot;operator&quot; : &quot;Equal&quot;,
        &quot;value&quot; : &quot;grafana&quot;,
        &quot;effect&quot; : &quot;NoSchedule&quot;
      }
    ]
  }
}
</code></pre>
<pre><code>resource &quot;helm_release&quot; &quot;victoria_metrics&quot; {
  name        = var.vm_release_name
  ...
  values = [
    yamlencode(local.victoria_values)
  ]
}
</code></pre>

Rostyslav Malenko
<p>Try <strong>dynamic</strong> block</p>
<pre><code>dynamic &quot;toleration&quot; {
            for_each = var.tolerations
            content {
              key      = toleration.value[&quot;key&quot;]
              operator = toleration.value[&quot;operator&quot;]
              value    = toleration.value[&quot;value&quot;]
              effect   = toleration.value[&quot;effect&quot;]
            }
          }
</code></pre>
<p><strong>var</strong> file</p>
<pre><code>variable &quot;tolerations&quot; {
  type        = list(map(string))
  default     = []
  description = &quot;Tolerations to apply to deployment&quot;
}
</code></pre>
<p><strong>arg</strong></p>
<pre><code>tolerations = [
    {
      key      = &quot;node.kubernetes.io/role&quot;,
      operator = &quot;Equal&quot;,
      value    = &quot;true&quot;,
      effect   = &quot;NoSchedule&quot;
    }
  ]
</code></pre>
