Class: Aws::SharedCredentials
- Inherits:
-
Object
- Object
- Aws::SharedCredentials
- Includes:
- CredentialProvider
- Defined in:
- lib/aws-sdk-core/shared_credentials.rb
Constant Summary collapse
- KEY_MAP =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{ 'aws_access_key_id' => 'access_key_id', 'aws_secret_access_key' => 'secret_access_key', 'aws_session_token' => 'session_token', }
Instance Attribute Summary collapse
- #credentials ⇒ Credentials readonly
- #path ⇒ String readonly
- #profile_name ⇒ String readonly
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ SharedCredentials
constructor
Constructs a new SharedCredentials object.
- #inspect ⇒ Object private
-
#loadable? ⇒ Boolean
deprecated
Deprecated.
This method is no longer used.
Methods included from CredentialProvider
Constructor Details
#initialize(options = {}) ⇒ SharedCredentials
Constructs a new SharedCredentials object. This will load static (access_key_id, secret_access_key and session_token) AWS access credentials from an ini file, which supports profiles. The default profile name is ‘default’. You can specify the profile name with the ‘ENV` or with the :profile_name option.
To use credentials from the default credential resolution chain create a client without the credential option specified. You may access the resolved credentials through client.config.credentials.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/aws-sdk-core/shared_credentials.rb', line 34 def initialize( = {}) shared_config = Aws.shared_config @path = [:path] @path ||= shared_config.credentials_path @profile_name = [: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 = SharedConfig.new( credentials_path: @path, profile_name: @profile_name ) @credentials = config.credentials(profile: @profile_name) end end |
Instance Attribute Details
#credentials ⇒ Credentials (readonly)
59 60 61 |
# File 'lib/aws-sdk-core/shared_credentials.rb', line 59 def credentials @credentials end |
#path ⇒ String (readonly)
53 54 55 |
# File 'lib/aws-sdk-core/shared_credentials.rb', line 53 def path @path end |
#profile_name ⇒ String (readonly)
56 57 58 |
# File 'lib/aws-sdk-core/shared_credentials.rb', line 56 def profile_name @profile_name end |
Instance Method Details
#inspect ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
62 63 64 65 66 67 68 69 |
# File 'lib/aws-sdk-core/shared_credentials.rb', line 62 def inspect parts = [ self.class.name, "profile_name=#{profile_name.inspect}", "path=#{path.inspect}", ] "#<#{parts.join(' ')}>" end |
#loadable? ⇒ Boolean
76 77 78 |
# File 'lib/aws-sdk-core/shared_credentials.rb', line 76 def loadable? !path.nil? && File.exist?(path) && File.readable?(path) end |