dainis / terraform-provider-zabbix

MIT License
40 stars 34 forks source link

host and interface ip does not flatten iteration list #3

Closed kylixtan closed 7 years ago

kylixtan commented 7 years ago

error: interfaces.0.ip must be a single value, not a list host must be a single value, not a list

kylixtan commented 7 years ago

resource "zabbix_host" "nginx" { host = "${openstack_compute_instance_v2.nginx..access_ip_v4}" interfaces = [{ ip = "${openstack_compute_instance_v2.nginx..access_ip_v4}" main = true }] groups = ["${var.zabbix_hostgroup}"] templates = ["Linux"] }

try to creat multiple nginx server and register it

dainis commented 7 years ago

As far as I know, terraform part you supplied isn't supported by terraform syntax

To accomplish that something like this would work

resource "zabbix_host" "nginx" {
  count = "${var.count}"
  host = "${openstack_compute_instance_v2.nginx.*.access_ip_v4[count.index]}"
  interfaces = [{
    ip = "${openstack_compute_instance_v2.nginx.*.access_ip_v4[count.index]}"
    main = true
  }]
  groups = ["${var.zabbix_hostgroup}"]
  templates = ["Linux"]
}

https://www.terraform.io/docs/configuration/interpolation.html#using-templates-with-count