From 097ee0d67d65deb2877c8085fba4969dc1385558 Mon Sep 17 00:00:00 2001 From: TangBin Date: Wed, 5 Dec 2018 20:48:00 +0800 Subject: [PATCH] sync security group bugfix --- pkg/util/aws/utils.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/util/aws/utils.go b/pkg/util/aws/utils.go index d3b823bc2f..5dae2446d9 100644 --- a/pkg/util/aws/utils.go +++ b/pkg/util/aws/utils.go @@ -226,7 +226,8 @@ func yunionPortRangeToAws(r secrules.SecurityRule) []portRange { portranges = append(portranges, portRange{int64(start), int64(end)}) } - for _, port := range r.Ports { + for i, _ := range r.Ports { + port := r.Ports[i] if port <= 0 && (r.Protocol == "tcp" || r.Protocol == "udp") { portranges = append(portranges, portRange{0, 65535}) } else if port <= 0 { @@ -322,7 +323,8 @@ func YunionSecRuleToAws(rule secrules.SecurityRule) ([]*ec2.IpPermission, error) portranges := yunionPortRangeToAws(rule) protocol := yunionProtocolToAws(rule) permissions := []*ec2.IpPermission{} - for _, port := range portranges { + for i, _ := range portranges { + port := portranges[i] permission := ec2.IpPermission{ FromPort: &port.Start, IpProtocol: &protocol,