provider/aws: fix CheckDestroy on aws_instance tests
This commit is contained in:
parent
894e6cabbb
commit
c8319d3b72
|
@ -540,27 +540,26 @@ func testAccCheckInstanceDestroyWithProvider(s *terraform.State, provider *schem
|
|||
}
|
||||
|
||||
// Try to find the resource
|
||||
var err error
|
||||
resp, err := conn.DescribeInstances(&ec2.DescribeInstancesInput{
|
||||
InstanceIds: []*string{aws.String(rs.Primary.ID)},
|
||||
})
|
||||
if err == nil {
|
||||
if len(resp.Reservations) > 0 {
|
||||
return fmt.Errorf("still exist.")
|
||||
for _, r := range resp.Reservations {
|
||||
for _, i := range r.Instances {
|
||||
if i.State != nil && *i.State.Name != "terminated" {
|
||||
return fmt.Errorf("Found unterminated instance: %s", i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Verify the error is what we want
|
||||
ec2err, ok := err.(awserr.Error)
|
||||
if !ok {
|
||||
return err
|
||||
if ae, ok := err.(awserr.Error); ok && ae.Code() == "InvalidInstanceID.NotFound" {
|
||||
continue
|
||||
}
|
||||
if ec2err.Code() != "InvalidInstanceID.NotFound" {
|
||||
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue