providers/aws: read properly finds the Self

This commit is contained in:
Mitchell Hashimoto 2014-09-30 14:26:01 -07:00
parent dbc890e401
commit 3b2272c69f
1 changed files with 11 additions and 1 deletions

View File

@ -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