Class: AWS::Core::CredentialProviders::ENVProvider
- Inherits:
-
Object
- Object
- AWS::Core::CredentialProviders::ENVProvider
- Includes:
- Provider
- Defined in:
- lib/aws/core/credential_providers.rb
Overview
Fetches credentials from the environment (ENV). You construct an ENV provider with a prefix. Given the prefix “AWS” ENV will be checked for the following keys:
-
AWS_ACCESS_KEY_ID
-
AWS_SECRET_ACCESS_KEY
-
AWS_SESSION_TOKEN (optional)
Constant Summary
Constants included from Provider
Instance Attribute Summary collapse
- #prefix ⇒ String readonly
Instance Method Summary collapse
-
#get_credentials ⇒ Hash
This method is called on a credential provider to fetch credentials.
-
#initialize(prefix) ⇒ ENVProvider
constructor
A new instance of ENVProvider.
Methods included from Provider
#access_key_id, #credentials, #refresh, #secret_access_key, #session_token
Constructor Details
#initialize(prefix) ⇒ ENVProvider
Returns a new instance of ENVProvider.
181 182 183 |
# File 'lib/aws/core/credential_providers.rb', line 181 def initialize prefix @prefix = prefix end |
Instance Attribute Details
#prefix ⇒ String (readonly)
186 187 188 |
# File 'lib/aws/core/credential_providers.rb', line 186 def prefix @prefix 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 cashed until the client calls Provider#refresh.
189 190 191 192 193 194 195 196 197 |
# File 'lib/aws/core/credential_providers.rb', line 189 def get_credentials credentials = {} KEYS.each do |key| if value = ENV["#{@prefix}_#{key.to_s.upcase}"] credentials[key] = value end end credentials end |