File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -249,22 +249,30 @@ func (p *Provider) createSecurityGroup(cache *AWS) error {
249249 cache .SecurityGroupid = * sgOutput .GroupId
250250
251251 // Enter the Ingress rules for the security group
252+ ipRangeMap := make (map [string ]bool )
252253 ipRanges := []types.IpRange {}
254+
253255 // First lookup for the IP address of the user
254256 ip , err := utils .GetIPAddress ()
255257 if err != nil {
256258 p .fail ()
257259 return fmt .Errorf ("error getting IP address: %v" , err )
258260 }
261+
262+ // Add the auto-detected IP to the map and list
263+ ipRangeMap [ip ] = true
259264 ipRanges = append (ipRanges , types.IpRange {
260265 CidrIp : & ip ,
261266 })
262267
263- // Then add the IP ranges from the spec
268+ // Then add the IP ranges from the spec, skipping duplicates
264269 for _ , ip := range p .Spec .IngressIpRanges {
265- ipRanges = append (ipRanges , types.IpRange {
266- CidrIp : & ip ,
267- })
270+ if ! ipRangeMap [ip ] {
271+ ipRangeMap [ip ] = true
272+ ipRanges = append (ipRanges , types.IpRange {
273+ CidrIp : & ip ,
274+ })
275+ }
268276 }
269277
270278 irInput := & ec2.AuthorizeSecurityGroupIngressInput {
You can’t perform that action at this time.
0 commit comments