# Combining local variables with for\_each

**URL:** <https://discuss.hashicorp.com/t/combining-local-variables-with-for-each/31092>\
**Category:** Terraform\
**Created:** [October 25, 2021, 11:29am UTC](https://discuss.hashicorp.com/t/combining-local-variables-with-for-each/31092 "2021-10-25T11:29:39Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![jbardin](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/jbardin/32/3325_2.png) [@jbardin](https://discuss.hashicorp.com/u/jbardin)\
**Post date:** [October 25, 2021, 3:51pm UTC](https://discuss.hashicorp.com/t/combining-local-variables-with-for-each/31092/2 "2021-10-25T15:51:00Z")

</div>

Hi @amcsi,

The `for_each` argument is used in resources in order to create multiple instances of that resource, but `locals` is not a block which can be repeated in that manner, and has no `for_each` argument.

What you are looking for are [for expressions](https://www.terraform.io/docs/language/expressions/for.html). While you cannot create multiple locals from a single expressions, you can for example create a list of maps assigned to a single local value with the structure in your example like so:

```auto
locals {
  hey = [for f in fileset("${path.module}/functions", "*.js") :
    {
      value = f
      something_else = "additional: ${f}"
    }
  ]
}

```

---

_[View the full topic](https://discuss.hashicorp.com/t/combining-local-variables-with-for-each/31092)._
