Sha256: d141b59ad307913539929bc4401a8c8c6ac0949ccef9168d6e36dc868a561938

Contents?: true

Size: 819 Bytes

Versions: 3

Compression:

Stored size: 819 Bytes

Contents

module AwsRotate
  class Base
    include AwsServices

    def initialize(options={})
      @options = options
      @config_path = options[:config] || "#{ENV['HOME']}/.aws/config"
      @credentials_path = options[:credentials] || "#{ENV['HOME']}/.aws/credentials"
      @profile = ENV['AWS_PROFILE'] || default_profile
    end

  private
    def default_profile
      if ENV['AWS_PROFILE'].nil?
        lines = IO.readlines(@credentials_path)
        default_found = lines.detect { |l| l =~ /\[default\]/ }
        'default' if default_found
      else
        abort("AWS_PROFILE must be set")
      end
    end

    def sh(command)
      # no puts so we dont puts out the secret key value
      # puts "=> #{command}" # uncomment to debug
      success = system(command)
      raise unless success
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
aws-rotate-0.4.0 lib/aws_rotate/base.rb
aws-rotate-0.3.0 lib/aws_rotate/base.rb
aws-rotate-0.2.0 lib/aws_rotate/base.rb