Class: Hibernate::ConfigLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/hibernate/config_loader.rb

Instance Method Summary collapse

Constructor Details

#initialize(config_path = 'config.yaml') ⇒ ConfigLoader

Returns a new instance of ConfigLoader.



5
6
7
8
9
10
# File 'lib/hibernate/config_loader.rb', line 5

def initialize(config_path = 'config.yaml')
  @config_path = config_path
  @config = load_config
  @profile = ENV['AWS_PROFILE'] || default_profile
  validate_config
end

Instance Method Details

#aws_credentialsObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/hibernate/config_loader.rb', line 12

def aws_credentials
   = @config.dig('aws_accounts', @profile)

  if .nil?
    raise "Profile #{@profile} not found in the configuration file."
  end

  {
    account_id: ['account_id'],
    region: ['region'],
    access_key_id: .dig('credentials', 'access_key_id'),
    secret_access_key: .dig('credentials', 'secret_access_key')
  }
end