Class: AwsAssumeRole::Credentials::Factories::Environment

Inherits:
AbstractFactory
  • Object
show all
Defined in:
lib/aws_assume_role/credentials/factories/environment.rb

Constant Summary

Constants included from AwsAssumeRole::Credentials::Factories

Types

Constants included from AwsAssumeRole

AwsAssumeRole::Config, DefaultProvider, VERSION

Instance Attribute Summary

Attributes inherited from AbstractFactory

#credentials, #profile, #region, #role_arn

Instance Method Summary collapse

Methods inherited from AbstractFactory

priority, register_if_complete, type

Methods included from Logging

included

Methods included from AwsAssumeRole

shared_config

Constructor Details

#initialize(_options) ⇒ Environment

Returns a new instance of Environment.


7
8
9
10
11
12
13
14
15
16
# File 'lib/aws_assume_role/credentials/factories/environment.rb', line 7

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

Instance Method Details

#envar(keys) ⇒ Object


18
19
20
21
22
23
# File 'lib/aws_assume_role/credentials/factories/environment.rb', line 18

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