Hcl2 length() of map issue


locals {
  nports = "${length({ "a" = "b"})}"

on mac, v1.0.3 getting:
job.hcl:34,15-22: Error in function call; Call to function “length” failed: collection must be a list, a map or a tuple.

Hi @traceypooh :wave:

This seems like a bug on our job parser…I was only able to use length on lists, even though our documentation says that it works on maps and strings as well:

locals {
  nports = "${length(["a", "b"])}"

Would you mind opening an issue for this in our repo?

Thank you!

sure, thanks!

i’m working around for now with (working):

length(keys({ "a" = "b"}))

1 Like