Class: AWS::Core::CredentialProviders::DefaultProvider
- Inherits:
-
Object
- Object
- AWS::Core::CredentialProviders::DefaultProvider
- Includes:
- Provider
- Defined in:
- lib/aws/core/credential_providers.rb
Overview
The default credential provider makes a best effort to locate your AWS credentials. It checks a variety of locations in the following order:
* Static credentials from AWS.config (e.g. AWS.config.access_key_id,
AWS.config.secret_access_key)
* The environment (e.g. ENV['AWS_ACCESS_KEY_ID'] or
ENV['AMAZON_ACCESS_KEY_ID'])
* EC2 metadata service (checks for credentials provided by
roles for instances).
Constant Summary
Constants included from Provider
Instance Attribute Summary collapse
- #providers ⇒ Array<Provider> readonly
Instance Method Summary collapse
- #credentials ⇒ Object
-
#initialize(static_credentials = {}) ⇒ DefaultProvider
constructor
A new instance of DefaultProvider.
- #refresh ⇒ Object
Methods included from Provider
#access_key_id, #secret_access_key, #session_token
Constructor Details
#initialize(static_credentials = {}) ⇒ DefaultProvider
Returns a new instance of DefaultProvider.
107 108 109 110 111 112 113 |
# File 'lib/aws/core/credential_providers.rb', line 107 def initialize static_credentials = {} @providers = [] @providers << StaticProvider.new(static_credentials) @providers << ENVProvider.new('AWS') @providers << ENVProvider.new('AMAZON') @providers << EC2Provider.new end |
Instance Attribute Details
#providers ⇒ Array<Provider> (readonly)
116 117 118 |
# File 'lib/aws/core/credential_providers.rb', line 116 def providers @providers end |
Instance Method Details
#credentials ⇒ Object
118 119 120 121 122 123 124 125 126 |
# File 'lib/aws/core/credential_providers.rb', line 118 def credentials providers.each do |provider| begin return provider.credentials rescue Errors::MissingCredentialsError end end raise Errors::MissingCredentialsError end |
#refresh ⇒ Object
128 129 130 131 132 |
# File 'lib/aws/core/credential_providers.rb', line 128 def refresh providers.each do |provider| provider.refresh end end |