Class: Jaxx::Environment

Inherits:
Object
  • Object
show all
Defined in:
lib/jaxx/environment.rb

Constant Summary collapse

DEFAULT_ARGS =
{ 'service_timeout' => 1 }
DEFAULT_CREDENTIALS =
{ :aws_access_key_id => "", :aws_secret_access_key => "", :aws_session_token => nil, :use_iam_profile => false }

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Environment

Returns a new instance of Environment.



16
17
18
# File 'lib/jaxx/environment.rb', line 16

def initialize args = {}
  @service_timeout = DEFAULT_ARGS.dup.merge(args).delete('service_timeout')
end

Instance Attribute Details

#service_timeoutObject (readonly)

Returns the value of attribute service_timeout.



14
15
16
# File 'lib/jaxx/environment.rb', line 14

def service_timeout
  @service_timeout
end

Instance Method Details

#credentialsObject



20
21
22
23
24
25
26
# File 'lib/jaxx/environment.rb', line 20

def credentials
  Timeout::timeout(service_timeout) do 
    DEFAULT_CREDENTIALS.merge Fog::Compute::AWS.fetch_credentials(:use_iam_profile => true)
  end
rescue Errno::EHOSTDOWN, Errno::EHOSTUNREACH, Timeout::Error => exc
  DEFAULT_CREDENTIALS
end