Sha256: bd08a5f5c5bf08c8a40658c9e4bc8a03160ec508dc5ad2072ddcc09647324768

Contents?: true

Size: 811 Bytes

Versions: 1

Compression:

Stored size: 811 Bytes

Contents

require_relative "abstract_factory"

class AwsAssumeRole::Credentials::Factories::Environment < AwsAssumeRole::Credentials::Factories::AbstractFactory
    type :credential_provider
    priority 10

    def initialize(_options, **)
        key =    %w[AWS_ACCESS_KEY_ID AMAZON_ACCESS_KEY_ID AWS_ACCESS_KEY]
        secret = %w[AWS_SECRET_ACCESS_KEY AMAZON_SECRET_ACCESS_KEY AWS_SECRET_KEY]
        token =  %w[AWS_SESSION_TOKEN AMAZON_SESSION_TOKEN]
        region = %w[AWS_DEFAULT_REGION]
        profile = %w[AWS_PROFILE]
        @credentials = Aws::Credentials.new(envar(key), envar(secret), envar(token))
        @region = envar(region)
        @profile = envar(profile)
    end

    def envar(keys)
        keys.each do |key|
            return ENV[key] if ENV.key?(key)
        end
        nil
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aws_assume_role-0.2.2 lib/aws_assume_role/credentials/factories/environment.rb