Class: Terraformer::Credentials::Aws

Inherits:
Object
  • Object
show all
Defined in:
lib/terraformer/credentials/aws.rb

Constant Summary collapse

KEYS =
%w(aws_region aws_access_key_id aws_secret_access_key).freeze

Class Method Summary collapse

Class Method Details

.get_from_options(options) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/terraformer/credentials/aws.rb', line 20

def self.get_from_options(options)
  KEYS.inject({}) do |credentials, key|
    aws_key = key.sub("aws_", "").to_sym
    credentials[aws_key] = options[key.to_sym].nil? ? options[key] : options[key.to_sym]
    credentials[aws_key] = ENV[key.upcase] if credentials[aws_key].nil?
    raise AwsMissingCredentals.new(key) if credentials[aws_key].nil?

    credentials
  end
end