Sha256: 2fa84990091ebb285ef3fafd9bf0814c782242ca34445db7bfe7d03792b4606a
Contents?: true
Size: 1.17 KB
Versions: 1
Compression:
Stored size: 1.17 KB
Contents
require 'aws-sdk' require 'yaml' require 'hashie' module AwsAuditor class AwsConfig < Hash include Hashie::Extensions::IndifferentAccess end class AWSSDK FILE_NAMES = %w[.aws.yml] def self.configuration(environment) @environment = environment load_config AWS.config({ :access_key_id => @config[:access_key_id], :secret_access_key => @config[:secret_access_key], :region => @config[:region] }) end def self.load_config return @config if @config @config = AwsConfig[YAML.load_file(config_path)] if @config.has_key? @environment @config = @config[@environment] else puts "Could not find AWS credentials for #{@environment} environment"; exit end @config[:region] ||= 'us-east-1' @config end def self.config_path if filepath = FILE_NAMES.detect {|filename| File.exists?(filename)} File.join(Dir.pwd, filepath) else old_dir = Dir.pwd Dir.chdir('..') if old_dir != Dir.pwd config_path else puts "Could not find #{FILE_NAMES.join(' or ')}"; exit end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
aws_auditor-0.1.3 | lib/aws_auditor/aws.rb |