東京リージョンのVPC内に t1.micro のスポットリクエストを送るときに使う
それっぽい値段を出す
AZ片側だけで判定(ap-northeast-1a)
立ち上げるマシンはLinux
Ruby2.0.0-p247
aws-sdk 1.22.0
require "aws-sdk"
AWS.config(
:access_key_id => "access_key_id",
:secret_access_key => "secret_access_key",
:region => "ap-northeast-1"
)
def soreppoi_price
ec2 = AWS::EC2.new
options = {
:instance_types => ["t1.micro"],
:availability_zone => "ap-northeast-1a",
:start_time => (Time.now - 60 * 60 * 24).iso8601,
:filters => [
{
:name => "product-description",
:values => ["Linux/UNIX (Amazon VPC)"],
}
],
}
resp = ec2.client.describe_spot_price_history(options)
resp[:spot_price_history_set].each {|history|
return history[:spot_price].to_f + 0.005
}
end
puts soreppoi_price
参考にしたもの
http://itsneatlife.blogspot.jp/2013/08/aws-sdk-rubyspot-instancepricing-history.html
http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/EC2/Client/V20131001.html#describe_spot_price_history-instance_method
http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeSpotPriceHistory.html (Supported Filters)