Method: Fog::AWS::Compute::Real#initialize
- Defined in:
- lib/fog/compute/aws.rb
#initialize(options = {}) ⇒ Real
Initialize connection to EC2
Notes
options parameter must include values for :aws_access_key_id and :aws_secret_access_key in order to create a connection
Examples
sdb = SimpleDB.new(
:aws_access_key_id => your_aws_access_key_id,
:aws_secret_access_key => your_aws_secret_access_key
)
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.
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/fog/compute/aws.rb', line 169 def initialize(={}) unless .delete(:provider) location = caller.first warning = "[yellow][WARN] Fog::AWS::Compute.new is deprecated, use Fog::Compute.new(:provider => 'AWS') instead[/]" warning << " [light_black](" << location << ")[/] " Formatador.display_line(warning) end require 'fog/core/parser' @aws_access_key_id = [:aws_access_key_id] @aws_secret_access_key = [:aws_secret_access_key] @hmac = Fog::HMAC.new('sha256', @aws_secret_access_key) if @endpoint = [:endpoint] endpoint = URI.parse(@endpoint) @host = endpoint.host @path = endpoint.path @port = endpoint.port @scheme = endpoint.scheme else [:region] ||= 'us-east-1' @host = [:host] || case [:region] when 'ap-southeast-1' 'ec2.ap-southeast-1.amazonaws.com' 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 raise ArgumentError, "Unknown region: #{options[:region].inspect}" end @path = [:path] || '/' @port = [:port] || 443 @scheme = [:scheme] || 'https' end @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", [:persistent]) end |