Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flatten a map to a list in terraform?

Tags:

terraform

I have this map:

  mymap = "${
      map(
      "key1", "111111",
      "key2", "222222",
      "key3", "333333"
      )
  }"

I need it as a map for some things but for other things I just need a list of values like this:

mymap = [
  "111111","222222","333333"
]

How can I convert the map to a list and store in another variable (in locals)?

like image 617
red888 Avatar asked Dec 31 '22 10:12

red888


1 Answers

Is the values function something you're looking for?

Using 0.12 syntax for clarity:

locals {
  myvalues = values(local.mymap)
}
like image 69
Marcin Wyszynski Avatar answered Jan 10 '23 10:01

Marcin Wyszynski