Skip to content

Commit

Permalink
Spot Instance Request: handle "closed" requests
Browse files Browse the repository at this point in the history
For one-time spot instance requests, when the instance is terminated,
the request is automatically marked as "closed" and removed by aws after
some time. This is same as "cancelled" requests. This change handles
"closed" state scenario and treats the request as deleted.
  • Loading branch information
darkowlzz committed Oct 15, 2017
1 parent 4fc6d6b commit fd5f541
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions aws/resource_aws_spot_instance_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ func resourceAwsSpotInstanceRequestRead(d *schema.ResourceData, meta interface{}

request := resp.SpotInstanceRequests[0]

// if the request is cancelled, then it is gone
if *request.State == "cancelled" {
// if the request is cancelled or closed, then it is gone
if *request.State == "cancelled" || *request.State == "closed" {
d.SetId("")
return nil
}
Expand Down
3 changes: 2 additions & 1 deletion aws/resource_aws_spot_instance_request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,9 @@ func testAccCheckAWSSpotInstanceRequestDestroy(s *terraform.State) error {
return nil
}

if *s.State == "canceled" {
if *s.State == "canceled" || *s.State == "closed" {
// Requests stick around for a while, so we make sure it's cancelled
// or closed.
return nil
}

Expand Down

0 comments on commit fd5f541

Please sign in to comment.