provider/aws: Fix issue in Security Group Rules where the Security Group is not found
This commit is contained in:
parent
6e7c6122e9
commit
f4fb053982
|
@ -152,7 +152,9 @@ func resourceAwsSecurityGroupRuleRead(d *schema.ResourceData, meta interface{})
|
||||||
sg_id := d.Get("security_group_id").(string)
|
sg_id := d.Get("security_group_id").(string)
|
||||||
sg, err := findResourceSecurityGroup(conn, sg_id)
|
sg, err := findResourceSecurityGroup(conn, sg_id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Printf("[DEBUG] Error finding Secuirty Group (%s) for Rule (%s): %s", sg_id, d.Id(), err)
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var rule *ec2.IPPermission
|
var rule *ec2.IPPermission
|
||||||
|
@ -256,6 +258,7 @@ func findResourceSecurityGroup(conn *ec2.EC2, id string) (*ec2.SecurityGroup, er
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if resp == nil || len(resp.SecurityGroups) != 1 || resp.SecurityGroups[0] == nil {
|
if resp == nil || len(resp.SecurityGroups) != 1 || resp.SecurityGroups[0] == nil {
|
||||||
return nil, fmt.Errorf(
|
return nil, fmt.Errorf(
|
||||||
"Expected to find one security group with ID %q, got: %#v",
|
"Expected to find one security group with ID %q, got: %#v",
|
||||||
|
|
|
@ -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
|
var group ec2.SecurityGroup
|
||||||
|
|
||||||
testRuleCount := func(*terraform.State) error {
|
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
|
var group ec2.SecurityGroup
|
||||||
|
|
||||||
testRuleCount := func(*terraform.State) error {
|
testRuleCount := func(*terraform.State) error {
|
||||||
|
|
Loading…
Reference in New Issue