# Iterate through map of sets and extract specific element

**URL:** <https://discuss.hashicorp.com/t/iterate-through-map-of-sets-and-extract-specific-element/48018>\
**Category:** Terraform\
**Created:** [December 15, 2022, 1:13pm UTC](https://discuss.hashicorp.com/t/iterate-through-map-of-sets-and-extract-specific-element/48018 "2022-12-15T13:13:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shapeofarchitect](https://avatars.discourse-cdn.com/v4/letter/s/a88e4f/32.png) [@shapeofarchitect](https://discuss.hashicorp.com/u/shapeofarchitect)\
**Post date:** [December 15, 2022, 1:13pm UTC](https://discuss.hashicorp.com/t/iterate-through-map-of-sets-and-extract-specific-element/48018/1 "2022-12-15T13:13:46Z")

</div>

Hi All,  
I am trying to iterate though a map of sets in my configuration which seems to work fine but I additionally have a requirement to extract a single element out of that as well , any help would be appreciated. Below is the code

```auto
variable "subnets" {
  type = map(set(object({
     name = string
     nets = set(string)
     deploy_true = bool
})))
}

#####
locals {
  net_pulls = flatten([for a in keys(var.subnets): 
    [for v in var.subnets[a]:
      {
        net_name = v.name
        net_type = v.nets
        net_deploy = v.deploy_true
      }
  ]
])

real_net_work = < extract single net_name here>
}

resource "key" "name" {
    for_each = {for c in local. net_pulls: c => c.net_name }
}

```

---

<div class="post-metadata">

**Author:** ![maxb](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/maxb/32/26655_2.png) [@maxb](https://discuss.hashicorp.com/u/maxb)\
**Post date:** [December 15, 2022, 5:54pm UTC](https://discuss.hashicorp.com/t/iterate-through-map-of-sets-and-extract-specific-element/48018/2 "2022-12-15T17:54:37Z")

</div>

> [@shapeofarchitect](#):
>
> I additionally have a requirement to extract a single element out of that as well

Could you give an example input and desired output, to clarify what you mean by that?
