mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
easier region switching for ec2
This commit is contained in:
parent
a264f29edf
commit
32f4af0ecf
1 changed files with 11 additions and 1 deletions
|
@ -109,6 +109,7 @@ module Fog
|
|||
#
|
||||
# ==== Parameters
|
||||
# * options<~Hash> - config arguments for connection. Defaults to {}.
|
||||
# * region<~String> - optional region to use, in ['eu-west-1', 'us-east-1', 'us-west-1']
|
||||
#
|
||||
# ==== Returns
|
||||
# * EC2 object with connection to aws.
|
||||
|
@ -120,7 +121,16 @@ module Fog
|
|||
raise ArgumentError.new('aws_secret_access_key is required to access ec2')
|
||||
end
|
||||
@hmac = HMAC::SHA256.new(@aws_secret_access_key)
|
||||
@host = options[:host] || 'ec2.amazonaws.com'
|
||||
@host = options[:host] || case options[:region]
|
||||
when 'eu-west-1'
|
||||
'ec2.eu-west-1.amazonaws.com'
|
||||
when 'us-east-1'
|
||||
'ec2.us-east-1.amazonaws.com'
|
||||
when 'us-west-1'
|
||||
'ec2.us-west-1.amazonaws.com'
|
||||
else
|
||||
'ec2.amazonaws.com'
|
||||
end
|
||||
@port = options[:port] || 443
|
||||
@scheme = options[:scheme] || 'https'
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue