gem install aws-sdk
aws-sdk-rubyをインストールした上で、使用しているAWSのID情報を設定し
以下のようなruby srouceを実行すると、spot instanceのpricing historyが取得出来ます。export AWS_ACCESS_KEY_ID='...' export AWS_SECRET_ACCESS_KEY='...' export AWS_REGION='ap-northeast-1'
実行結果。#!/usr/bin/env ruby require 'rubygems' require 'aws-sdk' ec2=AWS::EC2.new resp = ec2.client.describe_spot_price_history( :instance_types => ['m1.small', 'm1.medium', 'm1.large', 'm1.xlarge'], :start_time => (Time.now - 60 * 60 * 24).iso8601, :availability_zone => 'ap-northeast-1b') resp.data[:spot_price_history_set].map{ |history| if history[:product_description] == "Linux/UNIX" p history[:instance_type] + " => " + history[:spot_price] + " (" + history[:timestamp].to_s + ")" end }
"m1.small => 0.017000 (2013-08-01 22:52:34 UTC)" "m1.large => 0.067000 (2013-08-01 22:48:47 UTC)" "m1.medium => 0.035000 (2013-08-01 22:48:44 UTC)" "m1.xlarge => 0.134000 (2013-08-01 22:48:43 UTC)" "m1.small => 0.000100 (2013-08-01 22:47:34 UTC)" "m1.xlarge => 0.134000 (2013-08-01 13:12:40 UTC)" "m1.medium => 0.035000 (2013-08-01 06:47:28 UTC)" "m1.small => 0.017000 (2013-08-01 02:42:36 UTC)" "m1.large => 0.067000 (2013-08-01 00:04:50 UTC)" "m1.xlarge => 0.134000 (2013-07-31 13:11:39 UTC)" "m1.medium => 0.035000 (2013-07-31 06:44:00 UTC)"
0 件のコメント:
コメントを投稿