AWS: cancel spot instance request within a spot instace

故事扮演 提交于 2021-02-11 06:21:40

问题


I want to run data analysis using AWS that'll probably take a few days. I've setup a system where spot instances will reload the same EBS volume so it can resume the analysis after a termination. So far I've got it working where I can just generate a persistent spot request and have the analysis keep running and continue after spot instance terminations until it is done.

But I also want the spot instance to cancel the persistent spot instance request when the analysis is finished. Is there anyway to get the request ID from within the spot instance?


回答1:


The spot instance information is not available from the EC2 metadata. However, the instance ID is.

  1. Get the Instance ID from the EC2 metadata.
  2. Use DescribeInstances (or ec2-describe-instances, or aws ec2 describe-instances to get the instance information for the instance.
  3. Within the instance information is spotInstanceRequestId which is the spot instance request ID you're looking for.


来源:https://stackoverflow.com/questions/24289785/aws-cancel-spot-instance-request-within-a-spot-instace

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!