Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
152 views
in Technique[技术] by (71.8m points)

python - Deleting volumes when canceling a spot fleet request

I am trying to write a python script that terminates a spot fleet.

The boto3 API call cancel_spot_fleet_requests() conveniently provides TerminateInstances flag, that terminates all the instances.

Now I would also like to delete the spot volumes. I can do it in my script using boto3's delete_volume(). The problem is that I must wait until the instances fully terminate, and it takes too much time.

Ideally I would like to mark the volume for deletion when the instance terminates, and have AWS do it in the background.

Is that possible? Is there an XY alternative? (my goal is to delete the volumes without having to wait long time in my script until the instances terminate).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The solution turned out to be extremely simple. Since I create the instances from a template, there is an option to do "Delete on Termination". I simply updated the template so the flag will be True.

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...