provider/aws: Update testAccCheckAWSVpcPeeringConnectionDestroy to correctly check the destroyed state
This commit is contained in:
parent
26e0a3423b
commit
e2a7d4d98b
|
@ -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 fmt.Errorf("Fall through error for testAccCheckAWSVpcPeeringConnectionDestroy")
|
||||
}
|
||||
|
||||
func testAccCheckAWSVpcPeeringConnectionExists(n string, connection *ec2.VpcPeeringConnection) resource.TestCheckFunc {
|
||||
|
|
Loading…
Reference in New Issue