Skip to content

Commit afe36dc

Browse files
Always set IPv6 fields in Read to properly detect drift
Previously, ip6cidr and ip6gateway were only set in state when they had non-empty values from the API. This prevented Terraform from detecting drift when IPv6 configuration was removed or cleared server-side. Now these fields are always set from the API response (even if empty), allowing Terraform to properly detect when IPv6 has been removed and trigger a plan diff. The schema already handles avoiding unnecessary diffs when users haven't configured IPv6 (Optional + Computed fields).
1 parent f207255 commit afe36dc

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

cloudstack/resource_cloudstack_network.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -358,15 +358,9 @@ func resourceCloudStackNetworkRead(d *schema.ResourceData, meta interface{}) err
358358
d.Set("network_domain", n.Networkdomain)
359359
d.Set("vpc_id", n.Vpcid)
360360

361-
// Only set ip6cidr if it has a value
362-
if n.Ip6cidr != "" {
363-
d.Set("ip6cidr", n.Ip6cidr)
364-
}
365-
366-
// Only set ip6gateway if it has a value
367-
if n.Ip6gateway != "" {
368-
d.Set("ip6gateway", n.Ip6gateway)
369-
}
361+
// Always set IPv6 fields to detect drift when IPv6 is removed server-side
362+
d.Set("ip6cidr", n.Ip6cidr)
363+
d.Set("ip6gateway", n.Ip6gateway)
370364

371365
// Note: CloudStack API may not return startipv6 and endipv6 fields
372366
// These are typically only set during network creation

0 commit comments

Comments
 (0)