oracle / terraform-provider-oci

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

documentation discrepancy in resource oci_core_private_ip #2100

Open mhca99 opened 7 months ago

mhca99 commented 7 months ago

Community Note

Terraform Version and Provider Version

Terraform v1.7.3 on linux_amd64

Affected Resource(s)

oci_core_private_ip

Terraform Configuration Files

resource "oci_core_private_ip" "float_private_ip" {

  display_name   = "testvm-floatip"
  hostname_label = "testvm-floatip"
  ip_address     = "192.168.2.102"

}

Debug Output

│ Error: 400-MissingParameter, This request is missing one of the following arguments: subnetId, vnicId, vlanId. │ Suggestion: Please retry or contact support for help with service: Core Private Ip │ Documentation: https://registry.terraform.io/providers/oracle/oci/latest/docs/resources/core_private_ip │ API Reference: https://docs.oracle.com/iaas/api/#/en/iaas/20160918/PrivateIp/CreatePrivateIp │ Request Target: POST https://iaas.ca-toronto-1.oraclecloud.com/20160918/privateIps │ Provider version: 5.39.0, released on 2024-04-24. │ Service: Core Private Ip │ Operation Name: CreatePrivateIp

Panic Output

Expected Behavior

It should have created a private IP.

Actual Behavior

As per documentation , the vnic_id field is optional , however , its throwing error with missing vnicId . Further documentation does not reference any subnet_id , however its complaining about missing subnetId . When I tried to use the subnet_id , this resource does not recognize this field either. This documentation needs to be corrected , further we have a use case where we first deploy the infrastructure including the VCN, subnets and Route tables via main pipeline and then deploy the firewall VMs via separate pipeline. In main pipeline code, we require Route Table entry with firewall IP as next hop to force traffic through the firewall. This entry requires IP OCID which is not available during the first run as FW is not deployed yet. We wanted to use oci_core_private_ip to create the IP and inject its OCID in the routing table before deploying the firewall. And for the firewall VM, we wanted to use this IP in the "oci_core_vnic_attachment" resource , however it looks like that resource does not support attaching pre-existing IP (for that we will open another ticket/case). In a nutshell , we should be able to create an IP that later we can attach to existing or new NIC interface as Secondary IP.

Steps to Reproduce

  1. create VM with private IP resource with following code:
resource "oci_core_instance" "vm" {

  availability_domain = var.availability_domain_name
  compartment_id      = var.compute_compartment_ocid
  display_name        = "testvm"
  shape               = "VM.Standard.E4.Flex"

  shape_config {

    ocpus         = "4"
    memory_in_gbs = "4"
  }

  create_vnic_details {
    subnet_id              = var.vm-subnet
    display_name           = "testvm-main-nic"
    assign_public_ip       = false
    skip_source_dest_check = false
    hostname_label         = "testvm-vol1"
    private_ip             = "192.168.2.100"
  }

  source_details {
    source_type = "image"
    source_id   = var.image-id
  }

  timeouts {
    create = "60m"
  }
}

resource "oci_core_vnic_attachment" "vnic_attach_test" {

  instance_id  = oci_core_instance.vm.id
  display_name = "testvm-nic1-attchment"

  create_vnic_details {
    subnet_id              = var.vm-subnet
    display_name           = "testvm-nic1"
    hostname_label         = "testvm-nic1"
    assign_public_ip       = false
    skip_source_dest_check = true
    private_ip             = "192.168.2.101"

  }

}

resource "oci_core_private_ip" "float_private_ip" {

  display_name   = "testvm-floatip"
  hostname_label = "testvm-floatip"
  ip_address     = "192.168.2.102"

}

resource "oci_core_volume" "vm_volume" {
  availability_domain = var.availability_domain_name
  compartment_id      = var.compute_compartment_ocid
  display_name        = "testvm-osdisk1"
  size_in_gbs         = "50"

}

resource "oci_core_volume_attachment" "vm_volume_attach" {
  attachment_type = "paravirtualized"
  instance_id     = oci_core_instance.vm.id
  volume_id       = oci_core_volume.vm_volume.id
}
  1. terraform apply

Important Factoids

References