kohrar commented on issue #32:
URL: 
https://github.com/apache/cloudstack-terraform-provider/issues/32#issuecomment-1988777752

   Thanks @vishesh92 for finding out the behavior of the underlying API. Is 
this expected behavior? I'm not understanding why a networkid would be set to 
null if a VPC is in use.
   
   @kiranchavala sure. I'm trying to have terraform set up a port forwarding on 
an assigned IP address. Specifically, this is what my code looks like:
   ```
   resource "cloudstack_network" "galaxy-net" {
       project = "${var.cloudstack_project_id}"
       name = "galaxy-net" 
       display_text = "galaxy-net"
       cidr = "192.168.30.0/24"  
       network_offering = "UnrestrictedIsolatedNetworkOfferingForVpcNetworks"
       acl_id = "${cloudstack_network_acl.default.id}"
       vpc_id = "${cloudstack_vpc.default.id}"
       zone = "zone1"
   }
   
   resource "cloudstack_ipaddress" "galaxy_public_ip" {
       vpc_id = "${cloudstack_vpc.default.id}"
       network_id = "${cloudstack_network.galaxy-net.id}"
       zone = "zone1"                                  
       project = "${var.cloudstack_project_id}"
   }
   
   resource "cloudstack_port_forward" "expose_http_for_galaxy" {
       ip_address_id = "${cloudstack_ipaddress.galaxy_public_ip.id}"
       project = "${var.cloudstack_project_id}"
   
       forward {
           protocol  = "tcp"
           private_port = 80
           public_port = 80
           virtual_machine_id = "${cloudstack_instance.galaxy.id}"
       }
   
       forward {
           protocol  = "tcp"
           private_port = 443
           public_port = 443
           virtual_machine_id = "${cloudstack_instance.galaxy.id}"
       }
   }
   
   ```
   
   While we could get the network_id by other means, the issue here is that the 
.tfstate is not saving the network_id which results in the IP being re-created 
everytime terraform is applied because it detects a change (ie. network_id 
would change from null -> a known value).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to