oracle / terraform-provider-oci

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

Import of oci_core_vcn does not properly set IPv6 state #2215

Open nepeat opened 2 weeks ago

nepeat commented 2 weeks ago

Community Note

Terraform Version and Provider Version

OpenTofu v1.8.2
on darwin_arm64
+ provider registry.opentofu.org/hashicorp/oci v6.12.0

Affected Resource(s)

Terraform Configuration Files

resource "oci_core_vcn" "prod-vcn" {
    compartment_id = "${var.compartment_id}"

    display_name = "prod-vcn"
    is_ipv6enabled = true
    is_oracle_gua_allocation_enabled = false

    cidr_blocks = [
        "10.0.0.0/16",
    ]
    ipv6private_cidr_blocks = [
        // redacted
        "xxxx:xxxx:xxxx:xxxx::/56",
    ]
}

Debug Output

Not attached due to amount of confidential data.

Panic Output

N/A

Expected Behavior

No changes. Your infrastructure matches the configuration.

When importing an already existing VCN with IPv6 enabled and already existing prefixes, I expect that the state would be consistent with the file.

  1. IPv6 enablement can be assumed to be true if there are prefixes that already exist in the VCN.

If the actual behaviour is expected, the documentation should state whether or not allowing Terraform to change these states on apply would have any impact on already deployed resources since it is not clear if changes will be made.

Actual Behavior

What actually happens when importing an already existing VCN is that it does the following

  1. is_ipv6enabled is defaulting to false, despite the existence of IPv6 prefixes and enablement of IPv6 in the VCN.
  2. is_oracle_gua_allocation_enabled does not have a default value, which makes it part of the state that needs to be changed.
OpenTofu used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

OpenTofu will perform the following actions:

  # oci_core_vcn.prod-vcn will be updated in-place
  ~ resource "oci_core_vcn" "prod-vcn" {
        id                               = "ocid1.vcn.oc1.region.id"
      ~ is_ipv6enabled                   = false -> true
      + is_oracle_gua_allocation_enabled = false
        # (14 unchanged attributes hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Steps to Reproduce

  1. tofu import oci_core_vcn.prod-vcn ocid1.vcn.oc1.region.id
  2. terraform plan

Important Factoids

References

nepeat commented 1 week ago

PR #2226 made to handle this concern. Awaiting response from the CLA team for approval into the overall corporate CLA.

I am not sure if this is the right solution but it seems if the is_ipv6enabled flag is set properly, it negates the check for is_oracle_gua_allocation_enabled