Merge pull request #2897 from hashicorp/b-aws-sg-rule-ref

provider/aws: Fix issue in Security Group Rules where the Security Group is not found
This commit is contained in:
Clint 2015-07-30 16:12:35 -05:00
commit 6263d7b7ec
2 changed files with 5 additions and 2 deletions

View File

@ -152,7 +152,9 @@ func resourceAwsSecurityGroupRuleRead(d *schema.ResourceData, meta interface{})
sg_id := d.Get("security_group_id").(string)
sg, err := findResourceSecurityGroup(conn, sg_id)
if err != nil {
log.Printf("[DEBUG] Error finding Secuirty Group (%s) for Rule (%s): %s", sg_id, d.Id(), err)
d.SetId("")
return nil
}
var rule *ec2.IPPermission
@ -256,6 +258,7 @@ func findResourceSecurityGroup(conn *ec2.EC2, id string) (*ec2.SecurityGroup, er
if err != nil {
return nil, err
}
if resp == nil || len(resp.SecurityGroups) != 1 || resp.SecurityGroups[0] == nil {
return nil, fmt.Errorf(
"Expected to find one security group with ID %q, got: %#v",

View File

@ -105,7 +105,7 @@ func TestIpPermissionIDHash(t *testing.T) {
}
}
func TestAccAWSSecurityGroupRule_Ingress(t *testing.T) {
func TestAccAWSSecurityGroupRule_Ingress_VPC(t *testing.T) {
var group ec2.SecurityGroup
testRuleCount := func(*terraform.State) error {
@ -142,7 +142,7 @@ func TestAccAWSSecurityGroupRule_Ingress(t *testing.T) {
})
}
func TestAccAWSSecurityGroupRule_IngressClassic(t *testing.T) {
func TestAccAWSSecurityGroupRule_Ingress_Classic(t *testing.T) {
var group ec2.SecurityGroup
testRuleCount := func(*terraform.State) error {