What would be the way to get the AWS availability zone directly in the template
block?
The following doesn’t work, but just to show what I have tried so far.
job "redis" {
region = "us-east-1"
datacenters = ["us-east-1"]
group "cache" {
network {
port "db" {
to = 6379
}
}
task "redis" {
template {
data = <<EOT
your DC is [${NOMAD_DC}]
your DC is [${MY_DC}]
your AZ is [${attr.platform.aws.placement.availability-zone}]
EOT
destination = "local/one.txt"
}
template {
data = <<EOT
your DC is [${NOMAD_DC}]
your DC is [${MY_DC}]
your AZ is [${MY_AZ}]
EOT
destination = "local/two.txt"
}
driver = "docker"
config {
image = "redis:3.2"
auth_soft_fail = true
ports = ["db"]
}
env {
MY_DC="${NOMAD_DC}"
MY_AZ="${attr.platform.aws.placement.availability-zone}"
}
resources {
cpu = 500
memory = 256
}
}
}
}