title: Terraform Dynamic module from a map
body: <p>I'm trying to generate a dynamic aws_db_parameter_group from a map in terraform. I was wondering if what I'm trying to do is even possible. Here is a sample code:</p>
  <pre><code>provider &quot;aws&quot; {
  ...
  }
  
  variable &quot;key_values&quot; {
    type = map(string)
  
    default = {
      &quot;audit_trail&quot; = &quot;db,extended&quot;
      &quot;log_buffer&quot; = &quot;100&quot;
    }
  }
  
  resource &quot;aws_db_parameter_group&quot; &quot;test&quot; {
    family = &quot;oracle-ee&quot;
  
    name = &quot;test&quot;
  
    dynamic &quot;key_value&quot; {
      for_each = var.key_values
      content {
          name = key_value.key
          value = key_value.value
      }
    }
  }
  </code></pre>
  <p>The goal is that for each key, value in my variable, I want to generate a dynamic block with two values. One would be the key name and the second value would be value in the map. I've been reading this: <a href="https://www.terraform.io/docs/language/expressions/dynamic-blocks.html" rel="nofollow noreferrer">https://www.terraform.io/docs/language/expressions/dynamic-blocks.html</a></p>
  <p>And it looks like it is doable what I'm trying but I can't figure it out. Any suggestion?</p>
  <p>Regards,</p>