How converto map to tomap....?


tags = merge(
      map( # map ~> tomap
        "Name", format("%s-%s-ng2%s-eip", var.service_name, var.env, var.availability_zones.*.name_suffix[count.index])

I want to test version 1.0, how can I use the tomap grammar in the
existing map grammar?

You can just use { ... } syntax, so map( ... ) can be replaced by { ... } if that makes sense.

The tomap function expects a value of either a map type (in which case it will do nothing) or an object type (in which case it will convert it to a map).

For a “literal” map you can use it with an object construction expression, using braces:

tomap({ a = b })

In many cases you don’t need to explicitly use tomap, because Terraform can tell by context that a map is needed. For example, if you are assigning to an AWS resource type tags argument then the provider tells Terraform that this argument takes a map of strings and so Terraform will perform the conversion from object to map automatically, and thus you can just use the braces { a = b } without the conversion function.

Explicit conversion is most useful in situations where it is your own module code that as deciding a type. For example, the value argument in an output block has no assumed type and therefore if you want to return a map based on an object you will need to convert explicitly.