oracle / terraform-provider-oci

Terraform Oracle Cloud Infrastructure provider
https://www.terraform.io/docs/providers/oci/
Mozilla Public License 2.0
758 stars 680 forks source link

preserve original IP Address when load balancer is recreated #1649

Open tigermatos opened 2 years ago

tigermatos commented 2 years ago

Community Note

Description

Would it be possible to have an IP_Address property for oci_load_balancer_load_balancer, to explicitly assign a private IP to the load balancer?
Changes to Load Balancer property that does not support update will force the destruction and recreation of the load balancer, which results in a new IP Address assigned by the system. Then we need to update DNS name resolution, etc. Or perhaps the recreation process could be enhanced to internally lookup the current IP Address first, and then preserve it, by reusing the old IP.

New or Affected Resource(s)

oci_load_balancer_load_balancer and oci_network_load_balancer_network_load_balancer

References

https://registry.terraform.io/providers/oracle/oci/latest/docs/resources/load_balancer_load_balancer

johnlane commented 1 year ago

You can already do this. You must create a public IP and pass that in to the load balancer when you create it. Then you can create/destroy the load balancer without losing your public IP. Here's an example extracted from my code:

resource "oci_core_public_ip" "ip" {
  compartment_id = local.compartment_ocid
  display_name   = "${var.name}-public-ip"
  lifetime       = "RESERVED"
  lifecycle {
    prevent_destroy = true
  }
}

resource "oci_network_load_balancer_network_load_balancer" "nlb" {

   ....

  dynamic "reserved_ips" {
    content {
      id = oci_core_public_ip.ip.id
    }
  }
}

There is a bug to be aware of, however. See #1479 . I'm still waiting for an answer to that and using the workaround I posted there.

mhca99 commented 6 months ago

Hi, looks like this feature is still not available . The resource "oci_load_balancer_load_balancer" still does not support a dedicated private IP address for private load balancer use case without public IPs. It will require DNS record update everytime the private load balancer is created. Do we have any ETA when this feature will be available ?