moved terraform lab1 example back to deprecated floating ip assignment as new implementation does not set port id
This commit is contained in:
		
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -6,3 +6,4 @@ venv
 | 
			
		||||
**/terraform.tfstate.backup
 | 
			
		||||
**/.terraform.lock.hcl
 | 
			
		||||
**/.terraform
 | 
			
		||||
**/.terraform.tfstate.lock.info
 | 
			
		||||
 
 | 
			
		||||
@@ -14,7 +14,7 @@ variable "group_number" {
 | 
			
		||||
locals {
 | 
			
		||||
  auth_url        = "https://10.32.4.182:5000/v3"
 | 
			
		||||
  user_name       = "CloudComp${var.group_number}"
 | 
			
		||||
  user_password   = "<password of your group here, private-cloud is only reachable via vpn>"
 | 
			
		||||
  user_password = "<password of your group here, private-cloud is only reachable via vpn>"
 | 
			
		||||
  tenant_name     = "CloudComp${var.group_number}"
 | 
			
		||||
  #network_name    = "CloudComp${var.group_number}-net"
 | 
			
		||||
  router_name     = "CloudComp${var.group_number}-router"
 | 
			
		||||
@@ -165,6 +165,8 @@ resource "openstack_compute_instance_v2" "terraform-instance-1" {
 | 
			
		||||
  EOF
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
###########################################################################
 | 
			
		||||
#
 | 
			
		||||
# assign floating ip to instance
 | 
			
		||||
@@ -172,9 +174,27 @@ resource "openstack_compute_instance_v2" "terraform-instance-1" {
 | 
			
		||||
###########################################################################
 | 
			
		||||
resource "openstack_networking_floatingip_v2" "fip_1" {
 | 
			
		||||
  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" {
 | 
			
		||||
  value = openstack_networking_floatingip_v2.fip_1
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user