How to get the price of a running EC2 spot instance?

被刻印的时光 ゝ 提交于 2021-02-07 06:51:17

问题


I am trying to create ec2 spot instances using boto3 api, so far I am able to get the spot instance history price, spin up a spot instance, etc.

But I don't know how to get the price we are paying for spot instance using boto api.

anyone know how to do this ?

Thanks


回答1:


Update: See: Spot Instance Interruptions - Amazon Elastic Compute Cloud


Old answer:

When launching a spot instance under Amazon EC2, you specify a maximum hourly price, known as a bid. This is the maximum price that will be charged for the instance.

When the instance is launched, and on each hourly anniversary of the instance being in a running state, the instance will be charged at the then-current spot price.

If an instance is terminated due to the spot price rising above the bid price, then there is no charge for the partial hour where the instance was terminated. However, if the user terminates a spot instance, the partial hour will be charged.

Therefore, "the price we are paying for spot instance" is the price at the start of each hour. It is calculated at the time that the charge takes place.

To obtain the price charged for a spot instance, use the Spot Instance Data Feed that provides a data feed that describes your Spot Instance usage and pricing. This data feed is sent to an Amazon S3 bucket that you specify when you subscribe to the data feed. It is updated hourly.



来源:https://stackoverflow.com/questions/31529353/how-to-get-the-price-of-a-running-ec2-spot-instance

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