Class: Aws::InstanceProfileCredentials
- Inherits:
-
Credentials
- Object
- Credentials
- Aws::InstanceProfileCredentials
- Defined in:
- lib/aws-sdk-core/instance_profile_credentials.rb
Defined Under Namespace
Classes: Non200Response
Constant Summary collapse
- FAILURES =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
These are the errors we trap when attempting to talk to the instance metadata service. Any of these imply the service is not present, no responding or some other non-recoverable error.
[ Errno::EHOSTUNREACH, Errno::ECONNREFUSED, SocketError, Timeout::Error, Non200Response, ]
Instance Attribute Summary collapse
-
#retries ⇒ Integer
readonly
The number of times to retry failed atttempts to fetch credentials from the instance metadata service.
Instance Method Summary collapse
- #access_key_id ⇒ String?
- #expiration ⇒ Time?
-
#initialize(options = {}) ⇒ InstanceProfileCredentials
constructor
A new instance of InstanceProfileCredentials.
- #refresh! ⇒ Object
- #secret_access_key ⇒ String?
- #session_token ⇒ String?
Methods inherited from Credentials
Constructor Details
#initialize(options = {}) ⇒ InstanceProfileCredentials
Returns a new instance of InstanceProfileCredentials.
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/aws-sdk-core/instance_profile_credentials.rb', line 34 def initialize = {} @retries = [:retries] || 0 @ip_address = [:ip_address] || '169.254.169.254' @port = [:port] || 80 @http_open_timeout = [:http_open_timeout] || 1 @http_read_timeout = [:http_read_timeout] || 1 @http_debug_output = [:http_debug_output] @refresh_mutex = Mutex.new refresh! end |
Instance Attribute Details
#retries ⇒ Integer (readonly)
Returns The number of times to retry failed atttempts to fetch credentials from the instance metadata service. Defaults to 0.
47 48 49 |
# File 'lib/aws-sdk-core/instance_profile_credentials.rb', line 47 def retries @retries end |
Instance Method Details
#access_key_id ⇒ String?
50 51 52 53 |
# File 'lib/aws-sdk-core/instance_profile_credentials.rb', line 50 def access_key_id refresh_if_stale @access_key_id end |
#expiration ⇒ Time?
68 69 70 71 |
# File 'lib/aws-sdk-core/instance_profile_credentials.rb', line 68 def expiration refresh_if_stale @expiration end |
#refresh! ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/aws-sdk-core/instance_profile_credentials.rb', line 73 def refresh! @refresh_mutex.synchronize do credentials = MultiJson.load(get_credentials) @access_key_id = credentials['AccessKeyId'] @secret_access_key = credentials['SecretAccessKey'] @session_token = credentials['Token'] if expires = credentials['Expiration'] @expiration = Time.parse(expires) else @expiration = nil end end end |
#secret_access_key ⇒ String?
56 57 58 59 |
# File 'lib/aws-sdk-core/instance_profile_credentials.rb', line 56 def secret_access_key refresh_if_stale @secret_access_key end |
#session_token ⇒ String?
62 63 64 65 |
# File 'lib/aws-sdk-core/instance_profile_credentials.rb', line 62 def session_token refresh_if_stale @session_token end |