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