Skip to content

Commit 2c698d2

Browse files
committed
Always transform aws_security_group protocol to lower case
fixes hashicorp#5489
1 parent 642cf38 commit 2c698d2

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

builtin/providers/aws/resource_aws_security_group.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"log"
77
"sort"
8+
"strings"
89
"time"
910

1011
"github.com/aws/aws-sdk-go/aws"
@@ -817,7 +818,7 @@ func idHash(rType, protocol string, toPort, fromPort int64, self bool) string {
817818
buf.WriteString(fmt.Sprintf("%s-", rType))
818819
buf.WriteString(fmt.Sprintf("%d-", toPort))
819820
buf.WriteString(fmt.Sprintf("%d-", fromPort))
820-
buf.WriteString(fmt.Sprintf("%s-", protocol))
821+
buf.WriteString(fmt.Sprintf("%s-", strings.ToLower(protocol)))
821822
buf.WriteString(fmt.Sprintf("%t-", self))
822823

823824
return fmt.Sprintf("rule-%d", hashcode.String(buf.String()))

builtin/providers/aws/resource_aws_security_group_rules_matching_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,30 @@ func TestRulesMixedMatching(t *testing.T) {
186186
},
187187
},
188188
},
189+
// test lower/ uppercase handling
190+
{
191+
local: []interface{}{
192+
map[string]interface{}{
193+
"from_port": 80,
194+
"to_port": 8000,
195+
"protocol": "TCP",
196+
},
197+
},
198+
remote: []map[string]interface{}{
199+
map[string]interface{}{
200+
"from_port": int64(80),
201+
"to_port": int64(8000),
202+
"protocol": "tcp",
203+
},
204+
},
205+
saves: []map[string]interface{}{
206+
map[string]interface{}{
207+
"from_port": 80,
208+
"to_port": 8000,
209+
"protocol": "tcp",
210+
},
211+
},
212+
},
189213
// local and remote differ
190214
{
191215
local: []interface{}{

0 commit comments

Comments
 (0)