title: Iterate Through Map of Maps in Terraform 0.12
body: <p>I need to build a list of <code>templatefile</code>'s like this:</p>
  
  <pre><code>templatefile("${path.module}/assets/files_eth0.nmconnection.yaml", {
    interface-name = "eth0",
    addresses = element(values(var.virtual_machines), count.index),
    gateway = element(var.gateway, count.index % length(var.gateway)),
    dns = join(";", var.dns_servers),
    dns-search = var.domain,
    }),
  templatefile("${path.module}/assets/files_etc_hostname.yaml", {
    hostname = element(keys(var.virtual_machines), count.index),
    }),
  </code></pre>
  
  <p>by iterating over a map of maps like the following:</p>
  
  <pre><code>variable templatefiles {
    default = {
      "files_eth0.nmconnection.yaml" = {
        "interface-name" = "eth0",
        "addresses" = "element(values(var.virtual_machines), count.index)",
        "gateway" = "element(var.gateway, count.index % length(var.gateway))",
        "dns" = "join(";", var.dns_servers)",
        "dns-search" = "var.domain",
      },
      "files_etc_hostname.yaml" = {
        "hostname" = "host1"
      }
    }
  }
  </code></pre>
  
  <p>I've done something similar with a list of files:</p>
  
  <pre><code>file("${path.module}/assets/files_90-disable-console-logs.yaml"),
  file("${path.module}/assets/files_90-disable-auto-updates.yaml"),
  </code></pre>
  
  <p>...but would like to expand this to <code>templatefiles</code> (above).</p>
  
  <p>Here's the code I've done for the list of <code>files</code>:</p>
  
  <p><strong>main.tf</strong></p>
  
  <pre><code>variable files {
    default = [
      "files_90-disable-auto-updates.yaml",
      "files_90-disable-console-logs.yaml",
    ]
  }
  
  output "snippets" {
    value = flatten(module.ingition_snippets.files)
  }
  </code></pre>
  
  <p><strong>modules/main.tf</strong></p>
  
  <pre><code>variable files {}
  
  resource "null_resource" "files" {
    for_each = toset(var.files)
    triggers = {
      snippet = file("${path.module}/assets/${each.value}")
    }
  }
  
  output "files" {
    value = [for s in null_resource.files: s.triggers.*.snippet]
  }
  </code></pre>
  
  <p>Appreciate any help!</p>