Terraform openstack 实例不 return 浮动 ip

Terraform openstack instance doesn't return floating ip

我正在使用 terraform 设置和 openstack 实例。我正在写入一个返回 ip 的文件,但由于某种原因它总是空的(我查看了 openstack consol 中的实例,并且 ip、securitygroups 等的所有内容都是正确的)

resource "openstack_compute_instance_v2" "my-deployment-web" {
  count = "1"
  name = "my-name-WEB"
  flavor_name = "m1.medium"
  image_name = "RHEL7Secretname"
  security_groups = [
    "our_security_group"]
  key_pair = "our-keypair"   


  network {
    name = "public"
  }

  metadata {
    expire = "2",
    owner = ""
  }

  connection {
    type = "ssh"
    user = "vagrant"
    private_key = "config/vagrant_private.key"
    agent = "false"
    timeout = "15m"
  }

  ##Create Ansible host in staging inventory
  provisioner "local-exec" {
    command =  "echo -e '\n[web]\n${openstack_compute_instance_v2.my-deployment-web.network.0.floating_ip}' > ../ansible/inventories/staging/hosts"
    interpreter = ["sh", "-c"]
  }    
}

生成的host文件只有[web]没有ip。有人知道为什么吗?

[web]

修改来自

的变量
${openstack_compute_instance_v2.my-deployment-web.network.0.floating_ip}

${openstack_compute_instance_v2.my-deployment-web.network.0.access_ip_v4}

解决了问题。谢谢@Matt Schuchard