You are viewing documentation for version 1 of the AWS SDK for Ruby. Version 2 documentation can be found here.
Class: AWS::Core::CredentialProviders::SharedCredentialFileProvider
- Inherits:
-
Object
- Object
- AWS::Core::CredentialProviders::SharedCredentialFileProvider
- Includes:
- Provider
- Defined in:
- lib/aws/core/credential_providers.rb
Constant Summary
Constant Summary
Constants included from Provider
Instance Attribute Summary collapse
-
#path ⇒ String
readonly
-
#profile_name ⇒ String
readonly
Instance Method Summary collapse
-
#get_credentials ⇒ Hash
This method is called on a credential provider to fetch credentials.
-
#initialize(options = {}) ⇒ SharedCredentialFileProvider
constructor
A new instance of SharedCredentialFileProvider.
-
#shared_credential_file_path ⇒ Object
Methods included from Provider
#access_key_id, #credentials, #refresh, #secret_access_key, #session_token, #set?
Constructor Details
#initialize(options = {}) ⇒ SharedCredentialFileProvider
Returns a new instance of SharedCredentialFileProvider
291 292 293 294 295 296 |
# File 'lib/aws/core/credential_providers.rb', line 291 def initialize( = {}) @path = [:path] || shared_credential_file_path @profile_name = [:profile_name] @profile_name ||= ENV['AWS_PROFILE'] @profile_name ||= 'default' end |
Instance Attribute Details
#path ⇒ String (readonly)
299 300 301 |
# File 'lib/aws/core/credential_providers.rb', line 299 def path @path end |
#profile_name ⇒ String (readonly)
302 303 304 |
# File 'lib/aws/core/credential_providers.rb', line 302 def profile_name @profile_name end |
Instance Method Details
#get_credentials ⇒ Hash
This method is called on a credential provider to fetch credentials. The credentials hash returned from this method will be cached until the client calls Provider#refresh.
305 306 307 308 309 310 311 |
# File 'lib/aws/core/credential_providers.rb', line 305 def get_credentials if File.exist?(path) && File.readable?(path) load_from_path else {} end end |
#shared_credential_file_path ⇒ Object
273 274 275 276 277 278 279 280 281 |
# File 'lib/aws/core/credential_providers.rb', line 273 def shared_credential_file_path if RUBY_VERSION < '1.9' msg = "Must specify the :path to your shared credential file when using" msg << " Ruby #{RUBY_VERSION}" raise ArgumentError, msg else File.join(Dir.home, '.aws', 'credentials') end end |