From 1c2c1a5edb4701cfe909bf5af018ae215dbe9fea Mon Sep 17 00:00:00 2001 From: clint shryock Date: Tue, 22 Dec 2015 11:08:09 -0600 Subject: [PATCH] provider/aws: Update tests destroy checks --- .../resource_aws_spot_instance_request_test.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/builtin/providers/aws/resource_aws_spot_instance_request_test.go b/builtin/providers/aws/resource_aws_spot_instance_request_test.go index 2fe9860a6..37bd93507 100644 --- a/builtin/providers/aws/resource_aws_spot_instance_request_test.go +++ b/builtin/providers/aws/resource_aws_spot_instance_request_test.go @@ -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 {