|
@ -165,6 +165,8 @@ resource "openstack_compute_instance_v2" "terraform-instance-1" { |
|
|
EOF |
|
|
EOF |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
########################################################################### |
|
|
########################################################################### |
|
|
# |
|
|
# |
|
|
# assign floating ip to instance |
|
|
# assign floating ip to instance |
|
@ -172,9 +174,27 @@ resource "openstack_compute_instance_v2" "terraform-instance-1" { |
|
|
########################################################################### |
|
|
########################################################################### |
|
|
resource "openstack_networking_floatingip_v2" "fip_1" { |
|
|
resource "openstack_networking_floatingip_v2" "fip_1" { |
|
|
pool = local.floating_net |
|
|
pool = local.floating_net |
|
|
port_id = openstack_compute_instance_v2.terraform-instance-1.network[0].port |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
resource "openstack_compute_floatingip_associate_v2" "terraform-instance-1-ip" { |
|
|
|
|
|
floating_ip = openstack_networking_floatingip_v2.fip_1.address |
|
|
|
|
|
instance_id = openstack_compute_instance_v2.terraform-instance-1.id |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# does not work, though openstack_compute_floatingip_associate_v2 is deprecated, |
|
|
|
|
|
# openstack_compute_instance_v2.terraform-instance-1.network[0].port is empty after instance creation: "" |
|
|
|
|
|
# |
|
|
|
|
|
#resource "openstack_networking_floatingip_associate_v2" "terraform-instance-1-ip" { |
|
|
|
|
|
# floating_ip = openstack_networking_floatingip_v2.fip_1.address |
|
|
|
|
|
# port_id = openstack_compute_instance_v2.terraform-instance-1.network[0].port |
|
|
|
|
|
#} |
|
|
|
|
|
# |
|
|
|
|
|
# even better, as soon as openstack_compute_instance_v2.terraform-instance-1.network[0].port is not "": |
|
|
|
|
|
#resource "openstack_networking_floatingip_v2" "fip_1" { |
|
|
|
|
|
# pool = local.floating_net |
|
|
|
|
|
# port_id = openstack_compute_instance_v2.terraform-instance-1.network[0].port |
|
|
|
|
|
#} |
|
|
|
|
|
|
|
|
output "vip_addr" { |
|
|
output "vip_addr" { |
|
|
value = openstack_networking_floatingip_v2.fip_1 |
|
|
value = openstack_networking_floatingip_v2.fip_1 |
|
|
} |
|
|
} |