From 1397c2d613605db3fb549bb9e61110e181a8c689 Mon Sep 17 00:00:00 2001 From: geemus Date: Wed, 2 Mar 2011 10:57:52 -0800 Subject: [PATCH] [aws] adding ap-northeast-1 (tokyo) region options --- lib/fog/aws/cloud_formation.rb | 17 ++++++++++++++++- lib/fog/aws/elb.rb | 3 +++ lib/fog/aws/rds.rb | 3 +++ lib/fog/aws/simpledb.rb | 17 ++++++++++++++++- lib/fog/compute/aws.rb | 2 ++ lib/fog/storage/aws.rb | 6 ++++-- 6 files changed, 44 insertions(+), 4 deletions(-) diff --git a/lib/fog/aws/cloud_formation.rb b/lib/fog/aws/cloud_formation.rb index 4c890efed..005dff28f 100644 --- a/lib/fog/aws/cloud_formation.rb +++ b/lib/fog/aws/cloud_formation.rb @@ -47,7 +47,22 @@ 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) - @host = options[:host] || 'cloudformation.us-east-1.amazonaws.com' + + options[:region] ||= 'us-east-1' + @host = options[:host] || case options[:region] + when 'ap-northeast-1' + 'cloudformation.ap-northeast-1.amazonaws.com' + when 'ap-southeast-1' + 'cloudformation.ap-southeast-1.amazonaws.com' + when 'eu-west-1' + 'cloudformation.eu-west-1.amazonaws.com' + when 'us-east-1' + 'cloudformation.us-east-1.amazonaws.com' + when 'us-west-1' + 'cloudformation.us-west-1.amazonaws.com' + else + raise ArgumentError, "Unknown region: #{options[:region].inspect}" + end @path = options[:path] || '/' @port = options[:port] || 443 @scheme = options[:scheme] || 'https' diff --git a/lib/fog/aws/elb.rb b/lib/fog/aws/elb.rb index 3f9251baf..7511b5e77 100644 --- a/lib/fog/aws/elb.rb +++ b/lib/fog/aws/elb.rb @@ -48,8 +48,11 @@ 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-northeast-1' + 'elasticloadbalancing.ap-northeast-1.amazonaws.com' when 'ap-southeast-1' 'elasticloadbalancing.ap-southeast-1.amazonaws.com' when 'eu-west-1' diff --git a/lib/fog/aws/rds.rb b/lib/fog/aws/rds.rb index 63f6425b1..6ebabcbf8 100644 --- a/lib/fog/aws/rds.rb +++ b/lib/fog/aws/rds.rb @@ -71,8 +71,11 @@ 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-northeast-1' + 'rds.ap-northeast-1.amazonaws.com' when 'ap-southeast-1' 'rds.ap-southeast-1.amazonaws.com' when 'eu-west-1' diff --git a/lib/fog/aws/simpledb.rb b/lib/fog/aws/simpledb.rb index cea096819..50dd75ab7 100644 --- a/lib/fog/aws/simpledb.rb +++ b/lib/fog/aws/simpledb.rb @@ -64,8 +64,23 @@ 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) - @host = options[:host] || 'sdb.amazonaws.com' @nil_string = options[:nil_string]|| 'nil' + + options[:region] ||= 'us-east-1' + @host = options[:host] || case options[:region] + when 'ap-northeast-1' + 'sdb.ap-northeast-1.amazonaws.com' + when 'ap-southeast-1' + 'sdb.ap-southeast-1.amazonaws.com' + when 'eu-west-1' + 'sdb.eu-west-1.amazonaws.com' + when 'us-east-1' + 'sdb.us-east-1.amazonaws.com' + when 'us-west-1' + 'sdb.us-west-1.amazonaws.com' + else + raise ArgumentError, "Unknown region: #{options[:region].inspect}" + end @path = options[:path] || '/' @port = options[:port] || 443 @scheme = options[:scheme] || 'https' diff --git a/lib/fog/compute/aws.rb b/lib/fog/compute/aws.rb index 3a903db20..7dd80ac67 100644 --- a/lib/fog/compute/aws.rb +++ b/lib/fog/compute/aws.rb @@ -188,6 +188,8 @@ module Fog else options[:region] ||= 'us-east-1' @host = options[:host] || case options[:region] + when 'ap-northeast-1' + 'ec2.ap-northeast-1.amazonaws.com' when 'ap-southeast-1' 'ec2.ap-southeast-1.amazonaws.com' when 'eu-west-1' diff --git a/lib/fog/storage/aws.rb b/lib/fog/storage/aws.rb index 8ca6c5840..4545c3545 100644 --- a/lib/fog/storage/aws.rb +++ b/lib/fog/storage/aws.rb @@ -188,12 +188,14 @@ module Fog @aws_secret_access_key = options[:aws_secret_access_key] options[:region] ||= 'us-east-1' @host = options[:host] || case options[:region] + when 'ap-northeast-1' + 's3-ap-northeast-1.amazonaws.com' + when 'ap-southeast-1' + 's3-ap-southeast-1.amazonaws.com' when 'eu-west-1' 's3-eu-west-1.amazonaws.com' 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