title: Dynamic Nested Blocks for modules
body: <p>I would like to create a module for the Azure Application Gateway.</p>
  
  <p>I want to disable some rule groups with the inline block disabled_rule_group, but how can I make this configurable in the module? This should be a optional variable.</p>
  
  <p>I found the <code>for_each</code> for the nested blocks.</p>
  
  <p>Example:</p>
  
  <pre class="lang-hcl prettyprint-override"><code>variable "disabled_rule_groups" {
    default     = [
      {
        rule_group_name = "REQUEST-931-APPLICATION-ATTACK-RFI"
        rules           = [
          931100,
          931130]
      },
      {
        rule_group_name = "REQUEST-942-APPLICATION-ATTACK-SQLI"
        rules           = [
          942100
        ]
      }
    ]
  }
  </code></pre>
  
  <pre class="lang-hcl prettyprint-override"><code>resource "azurerm_application_gateway" "AppGateway" {
    dynamic "disabled_rule_group" {
      for_each = [var.disabled_rule_groups]
      content {
        rule_group_name = disabled_rule_group.value.rule_group_name
        rules           = disabled_rule_group.value.rules
      }
    }
  }
  </code></pre>
  
  <p>This is not working however.</p>
  
  <p>Does anybody have an idea how to fix the syntax?</p>
  
  <p>Additionally, the variable <code>disabled_rule_groups</code> should be optional. So if no disabled_rule_groups is set the block should be disabled.
  How can i achieve this? Do i need a second boolean variable and a if in the for each?</p>