Browse Source

moved terraform lab1 example back to deprecated floating ip assignment as new implementation does not set port id

master
Sebastian Rieger 6 months ago
parent
commit
c0904de73e
  1. 1
      .gitignore
  2. 22
      terraform/lab1/lab1.tf

1
.gitignore

@ -6,3 +6,4 @@ venv
**/terraform.tfstate.backup **/terraform.tfstate.backup
**/.terraform.lock.hcl **/.terraform.lock.hcl
**/.terraform **/.terraform
**/.terraform.tfstate.lock.info

22
terraform/lab1/lab1.tf

@ -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
} }
Loading…
Cancel
Save