@@ -57,6 +57,12 @@ func resourceCloudStackNetworkACLRule() *schema.Resource {
57
57
Optional : true ,
58
58
Elem : & schema.Resource {
59
59
Schema : map [string ]* schema.Schema {
60
+ "rule_id" : {
61
+ Type : schema .TypeInt ,
62
+ Optional : true ,
63
+ Computed : true ,
64
+ },
65
+
60
66
"action" : {
61
67
Type : schema .TypeString ,
62
68
Optional : true ,
@@ -100,6 +106,11 @@ func resourceCloudStackNetworkACLRule() *schema.Resource {
100
106
Default : "ingress" ,
101
107
},
102
108
109
+ "description" : {
110
+ Type : schema .TypeString ,
111
+ Optional : true ,
112
+ },
113
+
103
114
"uuids" : {
104
115
Type : schema .TypeMap ,
105
116
Computed : true ,
@@ -198,6 +209,11 @@ func createNetworkACLRule(d *schema.ResourceData, meta interface{}, rule map[str
198
209
// Create a new parameter struct
199
210
p := cs .NetworkACL .NewCreateNetworkACLParams (rule ["protocol" ].(string ))
200
211
212
+ // If a rule ID is specified, set it
213
+ if ruleId , ok := rule ["rule_id" ].(int ); ok && ruleId > 0 {
214
+ p .SetNumber (ruleId )
215
+ }
216
+
201
217
// Set the acl ID
202
218
p .SetAclid (d .Id ())
203
219
@@ -214,6 +230,11 @@ func createNetworkACLRule(d *schema.ResourceData, meta interface{}, rule map[str
214
230
// Set the traffic type
215
231
p .SetTraffictype (rule ["traffic_type" ].(string ))
216
232
233
+ // Set the description
234
+ if desc , ok := rule ["description" ].(string ); ok && desc != "" {
235
+ p .SetReason (desc )
236
+ }
237
+
217
238
// If the protocol is ICMP set the needed ICMP parameters
218
239
if rule ["protocol" ].(string ) == "icmp" {
219
240
p .SetIcmptype (rule ["icmp_type" ].(int ))
@@ -623,6 +644,15 @@ func verifyNetworkACLParams(d *schema.ResourceData) error {
623
644
}
624
645
625
646
func verifyNetworkACLRuleParams (d * schema.ResourceData , rule map [string ]interface {}) error {
647
+ if ruleId , ok := rule ["rule_id" ]; ok && ruleId != nil {
648
+ if rId , ok := ruleId .(int ); ok && rId > 0 {
649
+ if rId < 1 || rId > 65535 {
650
+ return fmt .Errorf (
651
+ "%q must be between %d and %d inclusive, got: %d" , "rule_id" , 1 , 65535 , rId )
652
+ }
653
+ }
654
+ }
655
+
626
656
action := rule ["action" ].(string )
627
657
if action != "allow" && action != "deny" {
628
658
return fmt .Errorf ("Parameter action only accepts 'allow' or 'deny' as values" )
0 commit comments