only wait for spot fleet instance termination if requested

This commit is contained in:
William Bowling 2016-12-29 13:01:17 +11:00
parent e2f2f9c78e
commit 7faa755061
1 changed files with 7 additions and 1 deletions

View File

@ -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()),