title: Is there any way to set a Terraform ressource attribute using its name?
body: <p>Is there any way to set a Terraform resource attribute using its name?</p>
  <p>I would like to use a map variable containing a map/object and would like to dynamically set attribute on a resource based on that object using a loop.</p>
  <p>Basically be able to do something similar to helm_release set mechanism (<a href="https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release" rel="nofollow noreferrer">https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release</a>):</p>
  <pre><code>resource &quot;helm_release&quot; &quot;example&quot; {
    name       = &quot;my-redis-release&quot;
    ...
    set {
      name  = &quot;cluster.enabled&quot;
      value = &quot;true&quot;
    }
  </code></pre>
  <p>Ideally I would like to do something like taking a .yaml and load into a variable as a map/object, then use that variable in a module in a loop to set resources attributes :</p>
  <pre><code>var.attributes = { a = 4, d = 2 }
  
  resource &quot;type&quot; &quot;name&quot; {
     for_each = var.attributes
     .. 
     self[each.key]    = each.value
  } 
  </code></pre>
  <p>I am using terraform 0.14.</p>