Sha256: 23259f78c51d14e21597f2081d3a2d6198ded5324c8a0752df646da6e7632037

Contents?: true

Size: 690 Bytes

Versions: 12

Compression:

Stored size: 690 Bytes

Contents

module AwsMfaSecure
  class Exports < Base
    def initialize(options={})
      @options = options
      @aws_profile = aws_profile
    end

    def run
      unless iam_mfa?
        $stderr.puts "WARN: mfa_serial is not configured for this AWS_PROFILE=#{@aws_profile}"
        return
      end

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

      puts script
    end

    def script
      <<~EOL
        export AWS_ACCESS_KEY_ID=#{credentials["access_key_id"]}
        export AWS_SECRET_ACCESS_KEY=#{credentials["secret_access_key"]}
        export AWS_SESSION_TOKEN=#{credentials["session_token"]}
      EOL
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
aws-mfa-secure-0.4.0 lib/aws_mfa_secure/exports.rb
aws-mfa-secure-0.3.8 lib/aws_mfa_secure/exports.rb
aws-mfa-secure-0.3.7 lib/aws_mfa_secure/exports.rb
aws-mfa-secure-0.3.6 lib/aws_mfa_secure/exports.rb
aws-mfa-secure-0.3.5 lib/aws_mfa_secure/exports.rb
aws-mfa-secure-0.3.4 lib/aws_mfa_secure/exports.rb
aws-mfa-secure-0.3.3 lib/aws_mfa_secure/exports.rb
aws-mfa-secure-0.3.2 lib/aws_mfa_secure/exports.rb
aws-mfa-secure-0.3.1 lib/aws_mfa_secure/exports.rb
aws-mfa-secure-0.3.0 lib/aws_mfa_secure/exports.rb
aws-mfa-secure-0.2.0 lib/aws_mfa_secure/exports.rb
aws-mfa-secure-0.1.0 lib/aws_mfa_secure/exports.rb