Class: Aws::SharedCredentials
- Inherits:
-
Object
- Object
- Aws::SharedCredentials
- Includes:
- CredentialProvider
- Defined in:
- gems/aws-sdk-core/lib/aws-sdk-core/shared_credentials.rb
Instance Attribute Summary collapse
-
#credentials ⇒ Credentials
readonly
-
#path ⇒ String
readonly
-
#profile_name ⇒ String
readonly
Attributes included from CredentialProvider
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ SharedCredentials
constructor
Constructs a new SharedCredentials object.
-
#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['AWS_PROFILE']
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
.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'gems/aws-sdk-core/lib/aws-sdk-core/shared_credentials.rb', line 27 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)
52 53 54 |
# File 'gems/aws-sdk-core/lib/aws-sdk-core/shared_credentials.rb', line 52 def credentials @credentials end |
#path ⇒ String (readonly)
46 47 48 |
# File 'gems/aws-sdk-core/lib/aws-sdk-core/shared_credentials.rb', line 46 def path @path end |
#profile_name ⇒ String (readonly)
49 50 51 |
# File 'gems/aws-sdk-core/lib/aws-sdk-core/shared_credentials.rb', line 49 def profile_name @profile_name end |
Instance Method Details
#loadable? ⇒ Boolean
69 70 71 |
# File 'gems/aws-sdk-core/lib/aws-sdk-core/shared_credentials.rb', line 69 def loadable? !path.nil? && File.exist?(path) && File.readable?(path) end |