From 7faa755061007b4c9f307f33101323a6dc4c1899 Mon Sep 17 00:00:00 2001 From: William Bowling Date: Thu, 29 Dec 2016 13:01:17 +1100 Subject: [PATCH] only wait for spot fleet instance termination if requested --- builtin/providers/aws/resource_aws_spot_fleet_request.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/builtin/providers/aws/resource_aws_spot_fleet_request.go b/builtin/providers/aws/resource_aws_spot_fleet_request.go index 36db3ad41..8f1e1969f 100644 --- a/builtin/providers/aws/resource_aws_spot_fleet_request.go +++ b/builtin/providers/aws/resource_aws_spot_fleet_request.go @@ -935,11 +935,12 @@ func resourceAwsSpotFleetRequestUpdate(d *schema.ResourceData, meta interface{}) func resourceAwsSpotFleetRequestDelete(d *schema.ResourceData, meta interface{}) error { // http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CancelSpotFleetRequests.html conn := meta.(*AWSClient).ec2conn + terminateInstances := d.Get("terminate_instances_with_expiration").(bool) log.Printf("[INFO] Cancelling spot fleet request: %s", d.Id()) resp, err := conn.CancelSpotFleetRequests(&ec2.CancelSpotFleetRequestsInput{ SpotFleetRequestIds: []*string{aws.String(d.Id())}, - TerminateInstances: aws.Bool(d.Get("terminate_instances_with_expiration").(bool)), + TerminateInstances: aws.Bool(terminateInstances), }) if err != nil { @@ -958,6 +959,11 @@ func resourceAwsSpotFleetRequestDelete(d *schema.ResourceData, meta interface{}) return fmt.Errorf("[ERR] Spot Fleet request (%s) was not found to be successfully canceled, dangling resources may exit", d.Id()) } + // Only wait for instance termination if requested + if !terminateInstances { + return nil + } + return resource.Retry(5*time.Minute, func() *resource.RetryError { resp, err := conn.DescribeSpotFleetInstances(&ec2.DescribeSpotFleetInstancesInput{ SpotFleetRequestId: aws.String(d.Id()),