describe_spot_price_history返回的可用区域[eu-west-1a]无效

时间:2012-08-13 13:18:30

标签: ruby amazon-ec2 amazon-web-services

我正在使用AWS Ruby SDK,而且我正在使用describe_spot_price_history返回的错误消息进行堆叠。错误消息显示:无效的可用区域:eu-west-1a

此消息仅针对欧洲(eu-west-1a ...)的可用区域而不是美国东部的其他区域返回。你知道如何解决这个问题吗?谢谢!

这是我的红宝石脚本:

begin
  ec2 = AWS::EC2.new(
    :access_key_id => access_key,
    :secret_access_key => access_secret)

  response = ec2.client.describe_spot_price_history(
    :start_time => start_time,
    :end_time => end_time,
    :instance_types => instance_type,
    :product_descriptions => 'Linux/UNIX',
    :availability_zone => availability_zone
  )

  prices = Array.new(response.spot_price_history_set.map(&:spot_price))
  prices = prices.flatten.collect { |i| i.to_f }
  puts prices

rescue
  puts "Error: " + $!
  exit 1
end

1 个答案:

答案 0 :(得分:1)

只需将ec2终点参数添加到EC2.new

即可
  ec2 = AWS::EC2.new(
    :access_key_id => access_key,
    :secret_access_key => access_secret,
    :ec2_endpoint => 'ec2.eu-west-1.amazonaws.com')