@@ -32,7 +32,7 @@ func resourceScalewayRdbACL() *schema.Resource {
32
32
Description : "Instance on which the ACL is applied" ,
33
33
},
34
34
"acl_rules" : {
35
- Type : schema .TypeList ,
35
+ Type : schema .TypeSet ,
36
36
Required : true ,
37
37
Description : "List of ACL rules to apply" ,
38
38
Elem : & schema.Resource {
@@ -72,7 +72,7 @@ func resourceScalewayRdbACLCreate(ctx context.Context, d *schema.ResourceData, m
72
72
createReq := & rdb.SetInstanceACLRulesRequest {
73
73
Region : region ,
74
74
InstanceID : ID ,
75
- Rules : rdbACLExpand (d .Get ("acl_rules" )),
75
+ Rules : rdbACLExpand (d .Get ("acl_rules" ).( * schema. Set ) ),
76
76
}
77
77
78
78
_ , err = rdbAPI .SetInstanceACLRules (createReq , scw .WithContext (ctx ))
@@ -127,7 +127,7 @@ func resourceScalewayRdbACLUpdate(ctx context.Context, d *schema.ResourceData, m
127
127
req := & rdb.SetInstanceACLRulesRequest {
128
128
Region : region ,
129
129
InstanceID : ID ,
130
- Rules : rdbACLExpand (d .Get ("acl_rules" )),
130
+ Rules : rdbACLExpand (d .Get ("acl_rules" ).( * schema. Set ) ),
131
131
}
132
132
133
133
_ , err = rdbAPI .SetInstanceACLRules (req , scw .WithContext (ctx ))
@@ -145,7 +145,7 @@ func resourceScalewayRdbACLDelete(ctx context.Context, d *schema.ResourceData, m
145
145
return diag .FromErr (err )
146
146
}
147
147
aclruleips := make ([]string , 0 )
148
- for _ , acl := range rdbACLExpand (d .Get ("acl_rules" )) {
148
+ for _ , acl := range rdbACLExpand (d .Get ("acl_rules" ).( * schema. Set ) ) {
149
149
aclruleips = append (aclruleips , acl .IP .String ())
150
150
}
151
151
_ , err = rdbAPI .DeleteInstanceACLRules (& rdb.DeleteInstanceACLRulesRequest {
@@ -161,13 +161,13 @@ func resourceScalewayRdbACLDelete(ctx context.Context, d *schema.ResourceData, m
161
161
return nil
162
162
}
163
163
164
- func rdbACLExpand (data interface {} ) []* rdb.ACLRuleRequest {
164
+ func rdbACLExpand (data * schema. Set ) []* rdb.ACLRuleRequest {
165
165
type aclRule struct {
166
166
IP string
167
167
Description string
168
168
}
169
169
var res []* rdb.ACLRuleRequest
170
- for _ , rule := range data .([] interface {} ) {
170
+ for _ , rule := range data .List ( ) {
171
171
r := rule .(map [string ]interface {})
172
172
res = append (res , & rdb.ACLRuleRequest {
173
173
IP : expandIPNet (r ["ip" ].(string )),
0 commit comments