AWS: cancel spot instance request within a spot instace

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?


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

  • Get the Instance ID from the EC2 metadata.
  • Use DescribeInstances (or ec2-describe-instances , or aws ec2 describe-instances to get the instance information for the instance.
  • Within the instance information is spotInstanceRequestId which is the spot instance request ID you're looking for.
  • 链接地址: http://www.djcxy.com/p/67166.html

    上一篇: EC2竞价实例:如何启动任务,如何阻止它们?

    下一篇: AWS:取消现货实例中的现货实例请求