@@ -307,6 +307,12 @@ func createNetworkACLRule(d *schema.ResourceData, meta interface{}, rule map[str
307307
308308 // If protocol is TCP or UDP, create the rule (with or without port)
309309 if rule ["protocol" ].(string ) == "tcp" || rule ["protocol" ].(string ) == "udp" {
310+ // Check if deprecated ports field is used and reject it
311+ if portsSet , hasPortsSet := rule ["ports" ].(* schema.Set ); hasPortsSet && portsSet .Len () > 0 {
312+ log .Printf ("[ERROR] Attempt to create rule with deprecated ports field" )
313+ return fmt .Errorf ("The 'ports' field is no longer supported for creating new rules. Please use the 'port' field with separate rules for each port/range." )
314+ }
315+
310316 portStr , hasPort := rule ["port" ].(string )
311317
312318 if hasPort && portStr != "" {
@@ -427,6 +433,7 @@ func processTCPUDPRule(rule map[string]interface{}, ruleMap map[string]*cloudsta
427433 rule ["protocol" ] = r .Protocol
428434 rule ["traffic_type" ] = strings .ToLower (r .Traffictype )
429435 rule ["cidr_list" ] = cidrs
436+ rule ["rule_number" ] = r .Number
430437 * rules = append (* rules , rule )
431438 log .Printf ("[DEBUG] Added TCP/UDP rule with no port to state: %+v" , rule )
432439 }
@@ -458,6 +465,7 @@ func processPortForRule(portStr string, rule map[string]interface{}, ruleMap map
458465 rule ["protocol" ] = r .Protocol
459466 rule ["traffic_type" ] = strings .ToLower (r .Traffictype )
460467 rule ["cidr_list" ] = cidrs
468+ rule ["rule_number" ] = r .Number
461469
462470 return true
463471}
@@ -556,6 +564,7 @@ func resourceCloudStackNetworkACLRuleRead(d *schema.ResourceData, meta interface
556564 rule ["icmp_code" ] = r .Icmpcode
557565 rule ["traffic_type" ] = strings .ToLower (r .Traffictype )
558566 rule ["cidr_list" ] = cidrs
567+ rule ["rule_number" ] = r .Number
559568 rules = append (rules , rule )
560569 log .Printf ("[DEBUG] Added ICMP rule to state: %+v" , rule )
561570 }
@@ -589,6 +598,7 @@ func resourceCloudStackNetworkACLRuleRead(d *schema.ResourceData, meta interface
589598 rule ["protocol" ] = r .Protocol
590599 rule ["traffic_type" ] = strings .ToLower (r .Traffictype )
591600 rule ["cidr_list" ] = cidrs
601+ rule ["rule_number" ] = r .Number
592602 rules = append (rules , rule )
593603 log .Printf ("[DEBUG] Added ALL rule to state: %+v" , rule )
594604 }
@@ -760,13 +770,13 @@ func verifyNetworkACLRuleParams(d *schema.ResourceData, rule map[string]interfac
760770 // No additional test are needed
761771 log .Printf ("[DEBUG] Protocol 'all' validated" )
762772 case "tcp" , "udp" :
763- // Check if deprecated ports field is used (not allowed for new configurations )
773+ // Check if deprecated ports field is used (not allowed for any operations )
764774 portsSet , hasPortsSet := rule ["ports" ].(* schema.Set )
765775 portStr , hasPort := rule ["port" ].(string )
766776
767777 if hasPortsSet && portsSet .Len () > 0 {
768- log .Printf ("[ERROR] Deprecated ports field used in new configuration " )
769- return fmt .Errorf ("The 'ports' field is deprecated. Use 'port' instead for new configurations ." )
778+ log .Printf ("[ERROR] Deprecated ports field used - no longer supported " )
779+ return fmt .Errorf ("The 'ports' field is no longer supported. Please migrate to using the 'port' field with separate rules for each port/range ." )
770780 }
771781
772782 // Validate the new port field if used
0 commit comments