provider/aws: Update testAccCheckAWSVpcPeeringConnectionDestroy to correctly check the destroyed state

This commit is contained in:
clint shryock 2016-01-07 11:48:53 -06:00
parent 26e0a3423b
commit e2a7d4d98b
1 changed files with 22 additions and 4 deletions

View File

@ -70,14 +70,32 @@ func testAccCheckAWSVpcPeeringConnectionDestroy(s *terraform.State) error {
VpcPeeringConnectionIds: []*string{aws.String(rs.Primary.ID)},
})
if err == nil {
if len(describe.VpcPeeringConnections) != 0 {
return fmt.Errorf("vpc peering connection still exists")
if err != nil {
return err
}
var pc *ec2.VpcPeeringConnection
for _, c := range describe.VpcPeeringConnections {
if rs.Primary.ID == *c.VpcPeeringConnectionId {
pc = c
}
}
if pc == nil {
// not found
return nil
}
if pc.Status != nil {
if *pc.Status.Code == "deleted" {
return nil
}
return fmt.Errorf("Found vpc peering connection in unexpected state: %s", pc)
}
}
return nil
return fmt.Errorf("Fall through error for testAccCheckAWSVpcPeeringConnectionDestroy")
}
func testAccCheckAWSVpcPeeringConnectionExists(n string, connection *ec2.VpcPeeringConnection) resource.TestCheckFunc {