Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 847
roy Avatar asked Jul 21 '15 02:07

roy


1 Answers

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.

like image 132
John Rotenstein Avatar answered Oct 12 '22 23:10

John Rotenstein