Sha256: b386fd11917fbcb8f4d344f619101a1d39348957512ba0dd5e20241cd3e53d14

Contents?: true

Size: 717 Bytes

Versions: 6

Compression:

Stored size: 717 Bytes

Contents

module AwsMfaSecure
  class Session < Base
    def initialize(options={}, *argv)
      @options = options
      @argv = ["aws"] + argv
      @aws_profile = aws_profile
    end

    def run
      unless iam_mfa?
        exec(*@argv) # will never get pass this point if there's no mfa_serial setting
      end

      if fetch_creds?
        resp = get_session_token(shell: true)
        save_creds(resp.credentials.to_h)
      end

      # Set AWS_ values unless alredy set
      ENV['AWS_ACCESS_KEY_ID']     ||= credentials["access_key_id"]
      ENV['AWS_SECRET_ACCESS_KEY'] ||= credentials["secret_access_key"]
      ENV['AWS_SESSION_TOKEN']     ||= credentials["session_token"]
      exec(*@argv)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
aws-mfa-secure-0.3.3 lib/aws_mfa_secure/session.rb
aws-mfa-secure-0.3.2 lib/aws_mfa_secure/session.rb
aws-mfa-secure-0.3.1 lib/aws_mfa_secure/session.rb
aws-mfa-secure-0.3.0 lib/aws_mfa_secure/session.rb
aws-mfa-secure-0.2.0 lib/aws_mfa_secure/session.rb
aws-mfa-secure-0.1.0 lib/aws_mfa_secure/session.rb