Skip to content

Commit e4089ff

Browse files
Hao Liusrishtipmishra
authored andcommitted
Fix ipv6 bug causing backwards incompatibility for vcn
1 parent b3bab51 commit e4089ff

File tree

5 files changed

+23
-9
lines changed

5 files changed

+23
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- Fixed update and destroy operations for management resources for external databases
1010
- Fixed retry behavior for database and db_home resources to honor user timeouts
1111
- Added Operations Insights doc update to `autonomous_database` resource
12+
- Fixed backward incompatibility of vcn resource caused due to `is_ipv6enabled` field
1213

1314
## 4.24.0 (April 29, 2021)
1415

oci/core_vcn_realm_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func TestGovSpecificCoreVcnResource_basic(t *testing.T) {
4343
{
4444
Config: config + compartmentIdVariableStr + VcnResourceDependencies +
4545
generateResourceFromRepresentationMap("oci_core_vcn", "test_vcn", Optional, Create, representationCopyWithNewProperties(vcnRepresentation, map[string]interface{}{
46-
"is_ipv6enabled": Representation{repType: Optional, create: `true`},
46+
"is_ipv6enabled": Representation{repType: Optional, create: `false`},
4747
})),
4848
Check: resource.ComposeAggregateTestCheckFunc(
4949
resource.TestCheckResourceAttr(resourceName, "cidr_block", "10.0.0.0/16"),
@@ -53,8 +53,7 @@ func TestGovSpecificCoreVcnResource_basic(t *testing.T) {
5353
resource.TestCheckResourceAttr(resourceName, "dns_label", "dnslabel"),
5454
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
5555
resource.TestCheckResourceAttrSet(resourceName, "id"),
56-
resource.TestCheckResourceAttr(resourceName, "ipv6cidr_blocks.#", "1"),
57-
resource.TestCheckResourceAttr(resourceName, "is_ipv6enabled", "true"),
56+
resource.TestCheckResourceAttr(resourceName, "is_ipv6enabled", "false"),
5857
resource.TestCheckResourceAttrSet(resourceName, "state"),
5958

6059
func(s *terraform.State) (err error) {
@@ -68,7 +67,7 @@ func TestGovSpecificCoreVcnResource_basic(t *testing.T) {
6867
{
6968
Config: config + compartmentIdVariableStr + VcnResourceDependencies +
7069
generateResourceFromRepresentationMap("oci_core_vcn", "test_vcn", Optional, Update, representationCopyWithNewProperties(vcnRepresentation, map[string]interface{}{
71-
"is_ipv6enabled": Representation{repType: Optional, create: `true`},
70+
"is_ipv6enabled": Representation{repType: Optional, update: `true`},
7271
})),
7372
Check: resource.ComposeAggregateTestCheckFunc(
7473
resource.TestCheckResourceAttr(resourceName, "cidr_block", "10.0.0.0/16"),
@@ -97,7 +96,7 @@ func TestGovSpecificCoreVcnResource_basic(t *testing.T) {
9796
generateDataSourceFromRepresentationMap("oci_core_vcns", "test_vcns", Optional, Update, vcnDataSourceRepresentation) +
9897
compartmentIdVariableStr + VcnResourceDependencies +
9998
generateResourceFromRepresentationMap("oci_core_vcn", "test_vcn", Optional, Update, representationCopyWithNewProperties(vcnRepresentation, map[string]interface{}{
100-
"is_ipv6enabled": Representation{repType: Optional, create: `true`},
99+
"is_ipv6enabled": Representation{repType: Optional, update: `true`},
101100
})),
102101
Check: resource.ComposeAggregateTestCheckFunc(
103102
resource.TestCheckResourceAttr(datasourceName, "compartment_id", compartmentId),

oci/core_vcn_resource.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ func CoreVcnResource() *schema.Resource {
7777
Type: schema.TypeBool,
7878
Optional: true,
7979
Computed: true,
80-
ForceNew: true,
8180
},
8281

8382
// Computed
@@ -275,6 +274,19 @@ func (s *CoreVcnResourceCrud) Update() error {
275274
}
276275
}
277276
}
277+
278+
if _, ok := s.D.GetOkExists("is_ipv6enabled"); ok && s.D.HasChange("is_ipv6enabled") {
279+
enableIPv6Request := oci_core.AddIpv6VcnCidrRequest{}
280+
tmp := s.D.Id()
281+
enableIPv6Request.VcnId = &tmp
282+
enableIPv6Request.RequestMetadata.RetryPolicy = getRetryPolicy(s.DisableNotFoundRetries, "core")
283+
284+
_, err := s.Client.AddIpv6VcnCidr(context.Background(), enableIPv6Request)
285+
if err != nil {
286+
return err
287+
}
288+
}
289+
278290
request := oci_core.UpdateVcnRequest{}
279291

280292
if _, ok := s.D.GetOkExists("cidr_blocks"); ok && s.D.HasChange("cidr_blocks") {
@@ -371,6 +383,8 @@ func (s *CoreVcnResourceCrud) SetData() error {
371383

372384
if s.Res.Ipv6CidrBlocks != nil && len(s.Res.Ipv6CidrBlocks) > 0 {
373385
s.D.Set("is_ipv6enabled", true)
386+
} else {
387+
s.D.Set("is_ipv6enabled", nil)
374388
}
375389

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

oci/core_vcn_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func TestCoreVcnResource_basic(t *testing.T) {
162162
{
163163
Config: config + compartmentIdVariableStr + VcnResourceDependencies +
164164
generateResourceFromRepresentationMap("oci_core_vcn", "test_vcn", Optional, Update, representationCopyWithNewProperties(vcnRepresentation, map[string]interface{}{
165-
"is_ipv6enabled": Representation{repType: Optional, create: `true`},
165+
"is_ipv6enabled": Representation{repType: Optional, update: `true`},
166166
})),
167167
Check: resource.ComposeAggregateTestCheckFunc(
168168
resource.TestCheckResourceAttr(resourceName, "cidr_block", "10.0.0.0/16"),
@@ -190,7 +190,7 @@ func TestCoreVcnResource_basic(t *testing.T) {
190190
generateDataSourceFromRepresentationMap("oci_core_vcns", "test_vcns", Optional, Update, vcnDataSourceRepresentation) +
191191
compartmentIdVariableStr + VcnResourceDependencies +
192192
generateResourceFromRepresentationMap("oci_core_vcn", "test_vcn", Optional, Update, representationCopyWithNewProperties(vcnRepresentation, map[string]interface{}{
193-
"is_ipv6enabled": Representation{repType: Optional, create: `true`},
193+
"is_ipv6enabled": Representation{repType: Optional, update: `true`},
194194
})),
195195
Check: resource.ComposeAggregateTestCheckFunc(
196196
resource.TestCheckResourceAttr(datasourceName, "compartment_id", compartmentId),

website/docs/r/core_vcn.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ The following arguments are supported:
9090

9191
Example: `vcn1`
9292
* `freeform_tags` - (Optional) (Updatable) Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Department": "Finance"}`
93-
* `is_ipv6enabled` - (Optional) Whether IPv6 is enabled for the VCN. Default is `false`. You cannot change this later. If enabled, Oracle will assign the VCN a IPv6 /56 CIDR block. For important details about IPv6 addressing in a VCN, see [IPv6 Addresses](https://docs.cloud.oracle.com/iaas/Content/Network/Concepts/ipv6.htm). Example: `true`
93+
* `is_ipv6enabled` - (Optional) Whether IPv6 is enabled for the VCN. Default is `false`. If enabled, Oracle will assign the VCN a IPv6 /56 CIDR block. Once added the IPv6 CIDR block cannot be removed or modified. For important details about IPv6 addressing in a VCN, see [IPv6 Addresses](https://docs.cloud.oracle.com/iaas/Content/Network/Concepts/ipv6.htm). Example: `true`
9494

9595

9696
** IMPORTANT **

0 commit comments

Comments
 (0)