You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ma...@apache.org on 2026/08/28 10:33:08 UTC

(cloudstack-terraform-provider) 01/03: Mark storage_network_ip_range netmask/start_ip/end_ip as ForceNew

This is an automated email from the ASF dual-hosted git repository.

sudo87 pushed a commit to branch fix/storage-range-import-project-displaytext
in repository https://gitbox.apache.org/repos/asf/cloudstack-terraform-provider.git

commit c1996e30aa088f8a16b330df6b60cf7e712d989b
Author: Manoj Kumar <ma...@gmail.com>
AuthorDate: Fri Aug 28 15:46:49 2026 +0530

    Mark storage_network_ip_range netmask/start_ip/end_ip as ForceNew
    
    CloudStack's updateStorageNetworkIpRange API validates a new IP range
    against the record's own current start/end IPs without excluding the
    record being updated, so any in-place edit of these fields fails with
    a self-overlap error (errorcode 530). Switching the update call to
    only send changed fields (d.HasChange instead of d.GetOk) did not
    help — the failure is identical even when only the genuinely-changed
    field is sent, confirming this is a server-side validation bug rather
    than something the provider can work around.
    
    Mark these fields ForceNew so the plan matches reality: Terraform now
    proposes a replacement instead of an update that is guaranteed to
    fail. Reproduced and reverified against ACS 4.23.0.0.
---
 .../resource_cloudstack_storage_network_ip_range.go   | 19 +++++++++++--------
 website/docs/r/storage_network_ip_range.html.markdown | 11 ++++++++++-
 2 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/cloudstack/resource_cloudstack_storage_network_ip_range.go b/cloudstack/resource_cloudstack_storage_network_ip_range.go
index 709108d..24d317e 100644
--- a/cloudstack/resource_cloudstack_storage_network_ip_range.go
+++ b/cloudstack/resource_cloudstack_storage_network_ip_range.go
@@ -47,6 +47,7 @@ func resourceCloudStackStorageNetworkIpRange() *schema.Resource {
 				Description: "the netmask for the storage network IP range",
 				Type:        schema.TypeString,
 				Required:    true,
+				ForceNew:    true,
 			},
 			"pod_id": {
 				Description: "the Pod ID for the storage network IP range",
@@ -58,12 +59,14 @@ func resourceCloudStackStorageNetworkIpRange() *schema.Resource {
 				Description: "the beginning IP address in the storage network IP range",
 				Type:        schema.TypeString,
 				Required:    true,
+				ForceNew:    true,
 			},
 			"end_ip": {
 				Description: "the ending IP address in the storage network IP range",
 				Type:        schema.TypeString,
 				Optional:    true,
 				Computed:    true,
+				ForceNew:    true,
 			},
 			"vlan": {
 				Description: "the optional VLAN of the storage network IP range",
@@ -136,17 +139,17 @@ func resourceCloudStackStorageNetworkIpRangeUpdate(d *schema.ResourceData, meta
 
 	p := cs.Network.NewUpdateStorageNetworkIpRangeParams(d.Id())
 
-	if v, ok := d.GetOk("netmask"); ok {
-		p.SetNetmask(v.(string))
+	if d.HasChange("netmask") {
+		p.SetNetmask(d.Get("netmask").(string))
 	}
-	if v, ok := d.GetOk("start_ip"); ok {
-		p.SetStartip(v.(string))
+	if d.HasChange("start_ip") {
+		p.SetStartip(d.Get("start_ip").(string))
 	}
-	if v, ok := d.GetOk("end_ip"); ok {
-		p.SetEndip(v.(string))
+	if d.HasChange("end_ip") {
+		p.SetEndip(d.Get("end_ip").(string))
 	}
-	if v, ok := d.GetOk("vlan"); ok {
-		p.SetVlan(v.(int))
+	if d.HasChange("vlan") {
+		p.SetVlan(d.Get("vlan").(int))
 	}
 
 	_, err := cs.Network.UpdateStorageNetworkIpRange(p)
diff --git a/website/docs/r/storage_network_ip_range.html.markdown b/website/docs/r/storage_network_ip_range.html.markdown
index 9deb789..5d1cf7e 100644
--- a/website/docs/r/storage_network_ip_range.html.markdown
+++ b/website/docs/r/storage_network_ip_range.html.markdown
@@ -33,11 +33,20 @@ The following arguments are supported:
   this forces a new resource to be created.
 - `gateway` - (Required) The gateway for the storage network IP range. Changing
   this forces a new resource to be created.
-- `netmask` - (Required) The netmask for the storage network IP range.
+- `netmask` - (Required) The netmask for the storage network IP range. Changing
+  this forces a new resource to be created.
 - `start_ip` - (Required) The beginning IP address in the storage network IP range.
+  Changing this forces a new resource to be created.
 - `end_ip` - (Optional) The ending IP address in the storage network IP range.
+  Changing this forces a new resource to be created.
 - `vlan` - (Optional) The optional VLAN of the storage network IP range.
 
+`netmask`, `start_ip`, and `end_ip` force replacement rather than an in-place
+update: CloudStack's `updateStorageNetworkIpRange` API validates a new range
+against the record's own current IPs without excluding the record being
+updated, so any in-place edit of these fields fails with an IP overlap error
+against itself.
+
 ## Attributes Reference
 
 The following attributes are exported: