Santhosh Kumar Tekuri
Santhosh Kumar Tekuri

Reputation: 3020

how to self terminate a spot instance once the task is done

I do not see that there is way to specify shutdownBehavior for spot instances. It only gives option to configure interruption behavior.

I would like to know, how to i terminate spot instance from within, once the task is done. is "shutdown -h now" is enough ?

Upvotes: 0

Views: 298

Answers (1)

John Rotenstein
John Rotenstein

Reputation: 270224

Yes, a spot instance can self-terminate with sudo shutdown now -h. (I just tried it, it worked!)

I notice that the Spot Request hangs around, with a status of instance-terminated-by-user, so you might want to delete it.

An alternative method would be for the instance to call describe-spot-instance-requests to discover its spot request ID (sir-) and then call cancel-spot-instance-requests. That would also terminate the instance, and would also cancel the spot request.

Upvotes: 1

Related Questions