Merge pull request #4420 from hashicorp/b-aws-s-test-updates

provider/aws: Update tests destroy checks
This commit is contained in:
Clint 2015-12-22 11:25:06 -06:00
commit 3fc370285b
1 changed files with 16 additions and 2 deletions

View File

@ -135,12 +135,26 @@ func testAccCheckAWSSpotInstanceRequestDestroy(s *terraform.State) error {
}
resp, err := conn.DescribeSpotInstanceRequests(req)
var s *ec2.SpotInstanceRequest
if err == nil {
if len(resp.SpotInstanceRequests) > 0 {
return fmt.Errorf("Spot instance request is still here.")
for _, sir := range resp.SpotInstanceRequests {
if sir.SpotInstanceRequestId != nil && *sir.SpotInstanceRequestId == rs.Primary.ID {
s = sir
}
continue
}
}
if s == nil {
// not found
return nil
}
if *s.State == "canceled" {
// Requests stick around for a while, so we make sure it's cancelled
return nil
}
// Verify the error is what we expect
ec2err, ok := err.(awserr.Error)
if !ok {