lib/awsecrets.rb in awsecrets-1.10.1 vs lib/awsecrets.rb in awsecrets-1.11.0
- old
+ new
@@ -3,11 +3,11 @@
require 'aws-sdk'
require 'aws_config'
require 'yaml'
module Awsecrets
- def self.load(profile: nil, region: nil, secrets_path: 'secrets.yml')
+ def self.load(profile: nil, region: nil, secrets_path: nil)
@profile = profile
@region = region
@secrets_path = secrets_path
@credentials = @access_key_id = @secret_access_key = @session_token = @role_arn = @source_profile = nil
@@ -46,18 +46,20 @@
def self.load_env
@region ||= ENV['AWS_REGION']
@region ||= ENV['AWS_DEFAULT_REGION']
@profile ||= ENV['AWS_PROFILE']
+ @secrets_path ||= ENV['AWS_SECRETS_PATH']
return if @access_key_id
return unless ENV['AWS_ACCESS_KEY_ID'] && ENV['AWS_SECRET_ACCESS_KEY']
@access_key_id ||= ENV['AWS_ACCESS_KEY_ID']
@secret_access_key ||= ENV['AWS_SECRET_ACCESS_KEY']
@session_token ||= ENV['AWS_SESSION_TOKEN']
end
def self.load_yaml
- creds = YAML.load_file(@secrets_path) if File.exist?(@secrets_path)
+ @secrets_path ||= 'secrets.yml'
+ creds = YAML.load_file(@secrets_path) if File.exist?(File.expand_path(@secrets_path))
@region ||= creds['region'] if creds && creds.include?('region')
return if @access_key_id
return unless creds &&
creds.include?('aws_access_key_id') &&
creds.include?('aws_secret_access_key')