title: Terraform - iterate over nested map
body: <p>I am trying to create IAM binding for Bigquery dataset using the resource - google_bigquery_dataset_iam_binding. The requirement is I read the parameters in this resource (dataset_id, role, members) using a variable of the following structure -</p>
  <pre><code>  bq_iam_role_bindings = {
      &quot;member1&quot; = {
        &quot;dataset1&quot; : [&quot;role1&quot;,&quot;role2&quot;, &quot;role5&quot;],
        &quot;dataset2&quot; : [&quot;role3&quot;,&quot;role2&quot;],
      },
      &quot;member2&quot; = {
        &quot;dataset3&quot; : [&quot;role1&quot;,&quot;role4&quot;],
        &quot;dataset2&quot; : [&quot;role5&quot;],
      } 
    }
  </code></pre>
  <p>So, I need to loop over this variable and get the roles assigned on a dataset for each member. Here total resources created would be eight (for each member, each dataset and each role).
  I am new to terraform and understand only how to apply simple for loop over a map and for_each loop in a resource. Want to understand how is it possible what I am trying to do.</p>
  <p>This is the nearest what I have found - <a href="https://stackoverflow.com/questions/56776130/map-within-a-map-in-terraform-variables">Map within a map in terraform variables</a> where I can read the value in a nested map but I need to extract key also in my case.
  Can anyone help here please.</p>