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.
184 185 186 |
# File 'lib/aws/core/credential_providers.rb', line 184 def initialize prefix @prefix = prefix end |
Instance Attribute Details
#prefix ⇒ String (readonly)
189 190 191 |
# File 'lib/aws/core/credential_providers.rb', line 189 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.
192 193 194 195 196 197 198 199 200 |
# File 'lib/aws/core/credential_providers.rb', line 192 def get_credentials credentials = {} KEYS.each do |key| if value = ENV["#{@prefix}_#{key.to_s.upcase}"] credentials[key] = value end end credentials end |