I have a map in Terraform, values of which I want to transform by prepending them with a string, resulting in another map.
variable "my_map" { type = map(string) } locals { my_new_map = [for key, value in var.my_map: { key = "prefix/${value}"}] }
But local.my_new_map is a tuple instead of a map. What am I missing for the result to be a map?
You must use the map syntax with { and } :
map
{
}
variable "my_map" { type = map(string) } locals { my_new_map = {for key, value in var.my_map: key => "prefix/${value}"} }
2.1m questions
2.1m answers
60 comments
57.0k users