From 3b2272c69f680510f83724145a0b404bf30f1abf Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 30 Sep 2014 14:26:01 -0700 Subject: [PATCH] providers/aws: read properly finds the Self --- builtin/providers/aws/resource_aws_security_group.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/builtin/providers/aws/resource_aws_security_group.go b/builtin/providers/aws/resource_aws_security_group.go index 1f627500c..71816cd7e 100644 --- a/builtin/providers/aws/resource_aws_security_group.go +++ b/builtin/providers/aws/resource_aws_security_group.go @@ -272,8 +272,18 @@ func resourceAwsSecurityGroupRead(d *schema.ResourceData, meta interface{}) erro n["cidr_blocks"] = perm.SourceIPs } + var groups []string if len(perm.SourceGroups) > 0 { - n["security_groups"] = flattenSecurityGroups(perm.SourceGroups) + groups = flattenSecurityGroups(perm.SourceGroups) + } + for i, id := range groups { + if id == d.Id() { + groups[i], groups = groups[len(groups)-1], groups[:len(groups)-1] + n["self"] = true + } + } + if len(groups) > 0 { + n["security_groups"] = groups } ingressRules[i] = n