对象列表(网络块)

时间:2017-03-04 23:05:05

标签: networking openstack terraform

openstack_compute_instance_v2中,Terraform可以附加现有网络,而我在模块中附加1或n个网络:

...

variable "vm_network" {
  type = "list"  
} 


resource "openstack_compute_instance_v2" "singlevm" {
    name            = "${var.vm_name}"
    image_id        = "${var.vm_image}"
    key_pair        = "${var.vm_keypair}"
    security_groups = "${var.vm_sg}"
    flavor_name     = "${var.vm_size}"
    network  = "${var.vm_network}"
}

在我的.tf文件中:

module "singlevm" {
    ...
    vm_network = {"name"="NETWORK1"}
    vm_network = {"name"="NETWORK2"}
}

Terraform返回expected object, got invalid错误。

我在这里做错了什么?

1 个答案:

答案 0 :(得分:1)

这不是您在.tf文件中指定源代码模块的列表的方式。

相反,你应该有更多的东西:

variable "vm_network" { default = [ "NETWORK1", "NETWORK2" ] }

module "singlevm" {
    ...
    vm_network = "${var.vm_network}"
}