[consul-template] How to give parameter to a template from the hcl config file

I try to set custom parameter via the template block in the hcl file without success.
We need to generate around 1000 nginx file based on the same template. On each file, the custom param would be used as a key for consul.

Is there a way to write code such as :

template {
  source = "/vhost"
  destination = "/vhosts/vhost_customer1.conf"
  params = { "ID" : "customer1" }
}

template {
  source = "/vhost"
  destination = "/vhosts/vhost2.conf"
  params = { "ID" : "customer2" }
}

template {
  source = "/vhost"
  destination = "/vhosts/vhost3.conf"
  params = { "ID" : "customer3" }
}

As a workaround, I tried to :

  • use an “env” key in the template but the “env” is only given for the exec block
  • get the destination filename from the template without success

Any suggestion ?