Module: AwsKeys
- Defined in:
- lib/aws_keys.rb,
lib/aws_keys/version.rb
Defined Under Namespace
Classes: NoAwsKeys
Constant Summary collapse
- VERSION =
"0.1.0"
Class Method Summary collapse
Class Method Details
.load(profile: nil, yml_file: ENV['HOME'] + "/.aws.yml") ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/aws_keys.rb', line 7 def self.load(profile: nil, yml_file: ENV['HOME'] + "/.aws.yml") aws_credential_path = ENV['HOME'] + "/aws/credentials" case when !(ENV.keys & %w[AWS_ACCESS_KEY AWS_SECRET_KEY]).empty? { "aws_access_key"=>ENV["AWS_ACCESS_KEY"], "aws_secret_key"=>ENV["AWS_SECRET_KEY"] } when File.exist?(yml_file) data = YAML.load_file(yml_file) profile.nil? ? data : data[profile] when File.exist?(aws_credential_path) file = IniFile.load(aws_credential_path) profile.nil? ? file["default"] : file[profile] else fail NoAwsKeys, "None of ENV variables, ~/aws/credentials or aws.yml were found" end end |