@@ -131,20 +131,24 @@ func resourceSecurityGroup() *schema.Resource {
131
131
"port_range_min" : & schema.Schema {
132
132
Type : schema .TypeInt ,
133
133
Optional : true ,
134
+ Default : 0 ,
134
135
ValidateDiagFunc : validatePortRange ,
135
136
},
136
137
"port_range_max" : & schema.Schema {
137
138
Type : schema .TypeInt ,
138
139
Optional : true ,
140
+ Default : 0 ,
139
141
ValidateDiagFunc : validatePortRange ,
140
142
},
141
143
"description" : & schema.Schema {
142
144
Type : schema .TypeString ,
143
145
Optional : true ,
146
+ Default : "" ,
144
147
},
145
148
"remote_ip_prefix" : & schema.Schema {
146
149
Type : schema .TypeString ,
147
150
Optional : true ,
151
+ Default : "" ,
148
152
},
149
153
"updated_at" : & schema.Schema {
150
154
Type : schema .TypeString ,
@@ -266,6 +270,7 @@ func resourceSecurityGroupRead(ctx context.Context, d *schema.ResourceData, m in
266
270
267
271
newSgRules := make ([]interface {}, len (sg .SecurityGroupRules ))
268
272
for i , sgr := range sg .SecurityGroupRules {
273
+ log .Printf ("rules: %+v" , sgr )
269
274
r := make (map [string ]interface {})
270
275
r ["id" ] = sgr .ID
271
276
r ["direction" ] = sgr .Direction .String ()
@@ -274,10 +279,9 @@ func resourceSecurityGroupRead(ctx context.Context, d *schema.ResourceData, m in
274
279
r ["ethertype" ] = sgr .EtherType .String ()
275
280
}
276
281
282
+ r ["protocol" ] = types .ProtocolAny
277
283
if sgr .Protocol != nil {
278
284
r ["protocol" ] = sgr .Protocol .String ()
279
- } else {
280
- r ["protocol" ] = types .ProtocolAny
281
285
}
282
286
283
287
r ["port_range_max" ] = 0
@@ -296,7 +300,7 @@ func resourceSecurityGroupRead(ctx context.Context, d *schema.ResourceData, m in
296
300
297
301
r ["remote_ip_prefix" ] = ""
298
302
if sgr .RemoteIPPrefix != nil {
299
- r ["remote_ip_prefix" ] = strings . TrimSuffix ( * sgr .RemoteIPPrefix , "/32" )
303
+ r ["remote_ip_prefix" ] = * sgr .RemoteIPPrefix
300
304
}
301
305
302
306
r ["updated_at" ] = sgr .UpdatedAt .String ()
0 commit comments