title: Terraform dynamically generate attributes (not blocks)
body: <p>I am trying to generate attributes dynamically in terraform 13. I've read through the docs but I can't seem to get this to work:</p>
  <p>Given the following terraform:</p>
  <pre><code>#main.tf
  
  locals {
    secrets = {
      secret1 = [
        {
          name  = &quot;user&quot;,
          value = &quot;secret&quot;
        },
        {
          name  = &quot;password&quot;,
          value = &quot;password123&quot;
        }
      ],
      secret2 = [
        {
          name  = &quot;token&quot;,
          value = &quot;secret&quot;
        }
      ]
    }
  }
  
  resource &quot;kubernetes_secret&quot; &quot;secrets&quot; {
    for_each = local.secret
  
    metadata {
      name = each.key
    }
  
    data = {
      [for name, value in each.value : name = value]
    }
  }
  </code></pre>
  <p>I would expect the following resources to be rendered:</p>
  <pre><code>resource &quot;kubernetes_secret&quot; &quot;secrets[secret1]&quot; {
    metadata {
      name = &quot;secret1&quot;
    }
  
    data = {
      user     = &quot;secret&quot;
      password = &quot;password123&quot;
    }
  }
  
  resource &quot;kubernetes_secret&quot; &quot;secrets[secret2]&quot; {
    metadata {
      name = &quot;secret2&quot;
    }
  
    data = {
      token = &quot;secret&quot;
    }
  }
  </code></pre>
  <p>However I just get the following error:</p>
  <pre><code>Error: Invalid 'for' expression
  
    on ../../main.tf line 96, in resource &quot;kubernetes_secret&quot; &quot;secrets&quot;:
    96:     [for name, value in each.value : name = value]
  
  Extra characters after the end of the 'for' expression.
  </code></pre>
  <p>Does anybody know how to make this work?</p>