Q:

Reduce map to string in terraform

I have a map variable that I would like to reduce to a single string. 
My variable looks like:
my_map = {
  key1 = "value1"
  key2 = "value2"
  key3 = "value3"
}

And I am hoping to reduce this to key1:value1,key2:value2,key3:value3. 
Checking terraform documentation I could not find any function to reduce a map but probably I am missing something. 
Any help would be appreciated. 

A:

You can get a list of the keys and another list of the values from the map by using the keys and values respectively. 
You can then format those lists into a list of strings of those lists joined together by a colon by using the formatlist function. 
And then finally you can get a single string of those elements of that list joined together by commas by using the join function. 
variable "my_map" {
  default = {
    key1 = "value1"
    key2 = "value2"
    key3 = "value3"
  }
}

locals {
  my_list = formatlist("%s:%s", keys(var.my_map), values(var.my_map))
}

output "my_string" {
  value = join(",", local.my_list)
}

