Merge pull request #2434 from hashicorp/b-sg-rule-crash
provider/aws: fix sg rule crash
This commit is contained in:
commit
7d26e1408a
|
@ -87,7 +87,7 @@ func resourceAwsSecurityGroupRuleCreate(d *schema.ResourceData, meta interface{}
|
||||||
sg, err := findResourceSecurityGroup(conn, sg_id)
|
sg, err := findResourceSecurityGroup(conn, sg_id)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("sorry")
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
perm := expandIPPerm(d, sg)
|
perm := expandIPPerm(d, sg)
|
||||||
|
@ -205,7 +205,7 @@ func resourceAwsSecurityGroupRuleDelete(d *schema.ResourceData, meta interface{}
|
||||||
sg, err := findResourceSecurityGroup(conn, sg_id)
|
sg, err := findResourceSecurityGroup(conn, sg_id)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("sorry")
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
perm := expandIPPerm(d, sg)
|
perm := expandIPPerm(d, sg)
|
||||||
|
@ -255,18 +255,12 @@ func findResourceSecurityGroup(conn *ec2.EC2, id string) (*ec2.SecurityGroup, er
|
||||||
}
|
}
|
||||||
resp, err := conn.DescribeSecurityGroups(req)
|
resp, err := conn.DescribeSecurityGroups(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if ec2err, ok := err.(awserr.Error); ok {
|
return nil, err
|
||||||
if ec2err.Code() == "InvalidSecurityGroupID.NotFound" ||
|
}
|
||||||
ec2err.Code() == "InvalidGroup.NotFound" {
|
if len(resp.SecurityGroups) != 1 {
|
||||||
resp = nil
|
return nil, fmt.Errorf(
|
||||||
err = nil
|
"Expected to find one security group with ID %q, got: %#v",
|
||||||
}
|
id, resp.SecurityGroups)
|
||||||
}
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("Error on findResourceSecurityGroup: %s", err)
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp.SecurityGroups[0], nil
|
return resp.SecurityGroups[0], nil
|
||||||
|
|
Loading…
Reference in New Issue