diff --git a/lib/fog/aws/ec2.rb b/lib/fog/aws/ec2.rb index 678a905c5..c78b7f594 100644 --- a/lib/fog/aws/ec2.rb +++ b/lib/fog/aws/ec2.rb @@ -152,6 +152,7 @@ @aws_access_key_id = options[:aws_access_key_id] @aws_secret_access_key = options[:aws_secret_access_key] @hmac = Fog::HMAC.new('sha256', @aws_secret_access_key) + options[:region] ||= 'us-east-1' @host = options[:host] || case options[:region] when 'ap-southeast-1' 'ec2.ap-southeast-1.amazonaws.com' @@ -162,7 +163,7 @@ when 'us-west-1' 'ec2.us-west-1.amazonaws.com' else - 'ec2.amazonaws.com' + raise ArgumentError, "Unknown region: #{options[:region].inspect}" end @port = options[:port] || 443 @scheme = options[:scheme] || 'https' diff --git a/lib/fog/aws/elb.rb b/lib/fog/aws/elb.rb index f9f67b29c..2dc0d497b 100644 --- a/lib/fog/aws/elb.rb +++ b/lib/fog/aws/elb.rb @@ -49,6 +49,7 @@ module Fog @aws_access_key_id = options[:aws_access_key_id] @aws_secret_access_key = options[:aws_secret_access_key] @hmac = Fog::HMAC.new('sha256', @aws_secret_access_key) + options[:region] ||= 'us-east-1' @host = options[:host] || case options[:region] when 'ap-southeast-1' 'elasticloadbalancing.ap-southeast-1.amazonaws.com' @@ -59,7 +60,7 @@ module Fog when 'us-west-1' 'elasticloadbalancing.us-west-1.amazonaws.com' else - 'elasticloadbalancing.amazonaws.com' + raise ArgumentError, "Unknown region: #{options[:region].inspect}" end @port = options[:port] || 443 @scheme = options[:scheme] || 'https' diff --git a/lib/fog/aws/s3.rb b/lib/fog/aws/s3.rb index 4716405da..c3bc0b6fc 100644 --- a/lib/fog/aws/s3.rb +++ b/lib/fog/aws/s3.rb @@ -125,13 +125,16 @@ module Fog @aws_access_key_id = options[:aws_access_key_id] @aws_secret_access_key = options[:aws_secret_access_key] @hmac = Fog::HMAC.new('sha1', @aws_secret_access_key) + options[:region] ||= 'us-east-1' @host = options[:host] || case options[:region] + when 'us-east-1' + 's3.amazonaws.com' when 'ap-southeast-1' 's3-ap-southeast-1.amazonaws.com' when 'us-west-1' 's3-us-west-1.amazonaws.com' else - 's3.amazonaws.com' + raise ArgumentError, "Unknown region: #{options[:region].inspect}" end @port = options[:port] || 443 @scheme = options[:scheme] || 'https'