terraform
terraform copied to clipboard
tomap is not evaluated on console
Terraform Version
Terraform v1.2.6
on linux_amd64
Terraform Configuration Files
none
Expected Behavior
tomap
should have been evaluated
Actual Behavior
It was not and was printed to the console
Steps to Reproduce
$ terraform console
> tomap({"a" = 1, "b" = 2})
tomap({
"a" = 1
"b" = 2
})
Example is take from docs https://www.terraform.io/language/functions/tomap
Hi @jamesmudd,
Thanks for filing the issue. The tomap
function is evaluated, but the output in the docs does not reflect the map type, which is differentiated from an object type using tomap
to mirror the syntax one would use the configuration. The behavior you see is correct.
Thanks!
Oh yes, indeed... when we originally wrote these docs Terraform CLI was written to present a map using the object syntax with no extra annotation, because that's how people typically produce a map value in situations where Terraform can infer an automatic conversion to a map. However, we learned over time that it was confusing because it made it hard to tell from the terraform console
output exactly what type of value was being returned, and so we changed the value renderer to include explicit tomap(...)
, tolist(...)
, and toset(...)
wrappers as a way to explicitly say "this value is a map, not an object" even though the Terraform language has no separate syntax for constructing maps.
Given that, I think what we have here is just outdated documentation: we changed the presentation in the UI without changing the examples in the docs that illustrate that behavior.
@apparentlymart @jbardin please let me fix this
Hi @RobertShan2000, I would recommend checking out the good first issue
tag in the terraform-provider-aws repository. They are soliciting new user contributions. Thanks for your interest!