From 665354246641ddeba09eaa488ee0755361704cf4 Mon Sep 17 00:00:00 2001 From: Jack Pearkes Date: Tue, 29 Jul 2014 12:45:57 -0400 Subject: [PATCH] providers/aws: fix order of ingress rules on security group --- builtin/providers/aws/resource_aws_security_group.go | 10 ++++++---- .../providers/aws/resource_aws_security_group_test.go | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/builtin/providers/aws/resource_aws_security_group.go b/builtin/providers/aws/resource_aws_security_group.go index 5b78524a4..1618e9ae4 100644 --- a/builtin/providers/aws/resource_aws_security_group.go +++ b/builtin/providers/aws/resource_aws_security_group.go @@ -49,8 +49,8 @@ func resource_aws_security_group_create( // Wait for the security group to truly exist log.Printf( - "[DEBUG] Waiting for SG (%s) to exist", - s.ID) + "[DEBUG] Waiting for Security Group (%s) to exist", + rs.ID) stateConf := &resource.StateChangeConf{ Pending: []string{""}, Target: "exists", @@ -59,7 +59,7 @@ func resource_aws_security_group_create( } if _, err := stateConf.WaitForState(); err != nil { return s, fmt.Errorf( - "Error waiting for SG (%s) to become available: %s", + "Error waiting for Security Group (%s) to become available: %s", rs.ID, err) } @@ -175,7 +175,9 @@ func resource_aws_security_group_update_state( n["security_groups"] = flattenSecurityGroups(perm.SourceGroups) } - ingressRules = append(ingressRules, n) + // Reverse the order, as Amazon sorts it the reverse of how we created + // it. + ingressRules = append([]map[string]interface{}{n}, ingressRules...) } toFlatten["ingress"] = ingressRules diff --git a/builtin/providers/aws/resource_aws_security_group_test.go b/builtin/providers/aws/resource_aws_security_group_test.go index 759381f0b..0b5876fd0 100644 --- a/builtin/providers/aws/resource_aws_security_group_test.go +++ b/builtin/providers/aws/resource_aws_security_group_test.go @@ -262,8 +262,8 @@ resource "aws_security_group" "web" { ingress { protocol = "tcp" - from_port = 80 - to_port = 8000 + from_port = 22 + to_port = 22 cidr_blocks = ["10.0.0.0/8"] }