Skip to content

Commit 10dd714

Browse files
nitimisMaxrovr
authored andcommitted
Bug Fix - Fix for VCN is_ipv6enabled plan drift on apply.
1 parent 4cbaecb commit 10dd714

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

examples/networking/vcn/vcn.tf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,25 @@ resource "oci_core_vcn" "vcn" {
3939
security_attributes = {"sample-namespace.value": "examplevalue", "sample-namespace.mode": "examplemode"}
4040
}
4141

42+
resource "oci_core_vcn" "test_vcn_ipv6" {
43+
compartment_id = var.compartment_ocid
44+
display_name = "test-vcn-ipv6"
45+
cidr_blocks = [
46+
"10.0.100.0/24",
47+
"10.0.101.0/24",
48+
]
49+
is_ipv6enabled = "true"
50+
is_oracle_gua_allocation_enabled = "false"
51+
ipv6private_cidr_blocks = [
52+
"2a04:4447:f001:100::/64",
53+
]
54+
}
55+
4256
output "vcn_id" {
4357
value = oci_core_vcn.vcn.id
4458
}
4559

60+
output "vcn_ipv6_id" {
61+
value = oci_core_vcn.test_vcn_ipv6.id
62+
}
63+

internal/integrationtest/core_vcn_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ var (
4848
CoreVcnRepresentation = map[string]interface{}{
4949
"cidr_block": acctest.Representation{RepType: acctest.Required, Create: `10.0.0.0/16`},
5050
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
51-
"defined_tags": acctest.Representation{RepType: acctest.Optional, Create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, Update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
51+
"defined_tags": acctest.Representation{RepType: acctest.Optional, Create: `${tomap({"${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}" = "value"})}`, Update: `${tomap({"${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}"= "updatedValue"})}`},
5252
"display_name": acctest.Representation{RepType: acctest.Optional, Create: `displayName`, Update: `displayName2`},
5353
"dns_label": acctest.Representation{RepType: acctest.Optional, Create: `dnslabel`},
5454
"freeform_tags": acctest.Representation{RepType: acctest.Optional, Create: map[string]string{"Department": "Finance"}, Update: map[string]string{"Department": "Accounting"}},
@@ -61,7 +61,7 @@ var (
6161
"is_ipv6enabled": acctest.Representation{RepType: acctest.Required, Create: `true`},
6262
"ipv6private_cidr_blocks": acctest.Representation{RepType: acctest.Required, Create: []string{`fc00:1000::/56`}},
6363
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
64-
"defined_tags": acctest.Representation{RepType: acctest.Optional, Create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, Update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
64+
"defined_tags": acctest.Representation{RepType: acctest.Optional, Create: `${tomap({"${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}"= "value"})}`, Update: `${tomap({"${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}"= "updatedValue"})}`},
6565
"display_name": acctest.Representation{RepType: acctest.Optional, Create: `displayName`, Update: `displayName2`},
6666
"dns_label": acctest.Representation{RepType: acctest.Optional, Create: `dnslabel`},
6767
"freeform_tags": acctest.Representation{RepType: acctest.Optional, Create: map[string]string{"Department": "Finance"}, Update: map[string]string{"Department": "Accounting"}},
@@ -103,7 +103,7 @@ func TestCoreVcnResource_basic(t *testing.T) {
103103
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
104104
resource.TestCheckResourceAttr(resourceName, "cidr_block", "10.0.0.0/16"),
105105
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
106-
106+
resource.TestCheckResourceAttr(resourceName, "is_ipv6enabled", "false"),
107107
func(s *terraform.State) (err error) {
108108
resId, err = acctest.FromInstanceState(s, resourceName, "id")
109109
return err

internal/service/core/core_vcn_resource.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,10 +597,10 @@ func (s *CoreVcnResourceCrud) SetData() error {
597597

598598
s.D.Set("security_attributes", tfresource.SecurityAttributesToMap(s.Res.SecurityAttributes))
599599

600-
if s.Res.Ipv6CidrBlocks != nil && len(s.Res.Ipv6CidrBlocks) > 0 {
600+
if (s.Res.Ipv6CidrBlocks != nil && len(s.Res.Ipv6CidrBlocks) > 0) || (s.Res.Ipv6PrivateCidrBlocks != nil && len(s.Res.Ipv6PrivateCidrBlocks) > 0) {
601601
s.D.Set("is_ipv6enabled", true)
602602
} else {
603-
s.D.Set("is_ipv6enabled", nil)
603+
s.D.Set("is_ipv6enabled", false)
604604
}
605605

606606
s.D.Set("state", s.Res.LifecycleState)

0 commit comments

Comments
 (0)