mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-07 14:44:11 -06:00
Merge pull request #10953 from Biteable/spot-fleet-terminate
only wait for spot fleet instance termination if requested
This commit is contained in:
commit
c453c6d189
@ -935,11 +935,12 @@ func resourceAwsSpotFleetRequestUpdate(d *schema.ResourceData, meta interface{})
|
|||||||
func resourceAwsSpotFleetRequestDelete(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsSpotFleetRequestDelete(d *schema.ResourceData, meta interface{}) error {
|
||||||
// http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CancelSpotFleetRequests.html
|
// http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CancelSpotFleetRequests.html
|
||||||
conn := meta.(*AWSClient).ec2conn
|
conn := meta.(*AWSClient).ec2conn
|
||||||
|
terminateInstances := d.Get("terminate_instances_with_expiration").(bool)
|
||||||
|
|
||||||
log.Printf("[INFO] Cancelling spot fleet request: %s", d.Id())
|
log.Printf("[INFO] Cancelling spot fleet request: %s", d.Id())
|
||||||
resp, err := conn.CancelSpotFleetRequests(&ec2.CancelSpotFleetRequestsInput{
|
resp, err := conn.CancelSpotFleetRequests(&ec2.CancelSpotFleetRequestsInput{
|
||||||
SpotFleetRequestIds: []*string{aws.String(d.Id())},
|
SpotFleetRequestIds: []*string{aws.String(d.Id())},
|
||||||
TerminateInstances: aws.Bool(d.Get("terminate_instances_with_expiration").(bool)),
|
TerminateInstances: aws.Bool(terminateInstances),
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
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())
|
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 {
|
return resource.Retry(5*time.Minute, func() *resource.RetryError {
|
||||||
resp, err := conn.DescribeSpotFleetInstances(&ec2.DescribeSpotFleetInstancesInput{
|
resp, err := conn.DescribeSpotFleetInstances(&ec2.DescribeSpotFleetInstancesInput{
|
||||||
SpotFleetRequestId: aws.String(d.Id()),
|
SpotFleetRequestId: aws.String(d.Id()),
|
||||||
|
Loading…
Reference in New Issue
Block a user