2

我正在使用 AWS Ruby SDK,并且与 describe_spot_price_history 返回的错误消息堆叠在一起。错误消息说:无效的可用区:eu-west-1a

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

这是我的红宝石脚本:

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
4

1 回答 1

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')
于 2012-08-13T13:59:00.593 回答