Using attr properties with lookup inside an env block

Hi

I’m trying to use attr.unique.hostname with the lookup() function to assing an environment variable a value like this in a job file:

variable "zookeeper_server_ids" {
  type = map(string)
  default = {
    "testserver03" = "1"
    "testserver04" = "2"
    "demoserver03" = "3"
  }
}
...
env {
  ZOOKEEPER_SERVER_ID="${lookup(var.zookeeper_server_ids, attr.unique.hostname, "MISSING")}"
}
...

I was expecting that this would give the correct value to the environment variable, but all hosts got the fallback value “MISSING”.

I replaced attr.unique.hostname with “testserver03” to test where the problem is. When given a hardcoded string, the lookup works just fine, snippet from nomad plan:

+/- Env[ZOOKEEPER_SERVER_ID]: "MISSING" => "1"

Reading the docs I got the impression that I could use node variables within my task.

Is this a undocumented restriction or am I doing something wrong?

Thanks for the help!