oracle-terraform-modules / terraform-oci-compute-instance

Terraform Module for creating Oracle Cloud Infrastructure compute instances
https://registry.terraform.io/modules/oracle-terraform-modules/compute-instance/oci/latest
Other
46 stars 62 forks source link

add reserved public ip to instance #55

Closed kral2 closed 3 years ago

kral2 commented 3 years ago

Currently, this module supports public ip only on primary vnic and primary IP, using assign_public_ip input (boolean).

To have the choice of both RESERVEDand EPHEMERAL with a consistent user experience, the public IP assignment logic needs to be removed from the create_vnic_details block and promoted as a distinct resource, using oci_core_public_ip.

Note: The primary vnic's primary IP OCID will need to get retrieved.

MikeK184 commented 1 year ago

How does one now assign a reserved public ip to an instance during first creation time? According to the Terraform docs oci_core_instance contains the following fields

    create_vnic_details {
        #Optional
        assign_private_dns_record = var.instance_create_vnic_details_assign_private_dns_record
        assign_public_ip = var.instance_create_vnic_details_assign_public_ip
        defined_tags = {"Operations.CostCenter"= "42"}
        display_name = var.instance_create_vnic_details_display_name
        freeform_tags = {"Department"= "Finance"}
        hostname_label = var.instance_create_vnic_details_hostname_label
        nsg_ids = var.instance_create_vnic_details_nsg_ids
        private_ip = var.instance_create_vnic_details_private_ip
        skip_source_dest_check = var.instance_create_vnic_details_skip_source_dest_check
        subnet_id = oci_core_subnet.test_subnet.id
        vlan_id = oci_core_vlan.test_vlan.id
    }

and the oci_core_public_ip

resource "oci_core_public_ip" "test_public_ip" {
    #Required
    compartment_id = var.compartment_id
    lifetime = var.public_ip_lifetime

    #Optional
    defined_tags = {"Operations.CostCenter"= "42"}
    display_name = var.public_ip_display_name
    freeform_tags = {"Department"= "Finance"}
    private_ip_id = oci_core_private_ip.test_private_ip.id
    public_ip_pool_id = oci_core_public_ip_pool.test_public_ip_pool.id
}

How does one bind the served IP to the vnic of the instance during creation/after creation. The docs doesn't seem to be clear on this...

teamsmiley commented 1 year ago

i have same problem, how to assign already reserved ip to instance

Rick6652 commented 1 year ago

I also have the same need

Egbert-Jan commented 1 year ago

Did you figure out how to assign a reserved ip to a compute instance?