Class: AwsAssumeRole::Credentials::Providers::SharedKeyringCredentials

Inherits:
Aws::SharedCredentials
  • Object
show all
Defined in:
lib/aws_assume_role/credentials/providers/shared_keyring_credentials.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ SharedKeyringCredentials

Returns a new instance of SharedKeyringCredentials.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/aws_assume_role/credentials/providers/shared_keyring_credentials.rb', line 5

def initialize(options = {})
    shared_config = AwsAssumeRole.shared_config
    @path = options[:path]
    @path ||= shared_config.credentials_path
    @profile_name = options[:profile_name]
    @profile_name ||= ENV["AWS_PROFILE"]
    @profile_name ||= shared_config.profile_name
    if @path && @path == shared_config.credentials_path
        @credentials = shared_config.credentials(profile: @profile_name)
    else
        config = AwsAssumeRole::Store::SharedConfig.new(
            credentials_path: @path,
            profile_name: @profile_name,
        )
        @credentials = config.credentials(profile: @profile_name)
    end
end