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 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.
32 33 34 35 36 37 38 39 40 |
# File 'lib/aws-sdk-core/instance_profile_credentials.rb', line 32 def initialize = {} @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 Method Details
#access_key_id ⇒ String?
43 44 45 46 |
# File 'lib/aws-sdk-core/instance_profile_credentials.rb', line 43 def access_key_id refresh_if_stale @access_key_id end |
#expiration ⇒ Time?
61 62 63 64 |
# File 'lib/aws-sdk-core/instance_profile_credentials.rb', line 61 def expiration refresh_if_stale @expiration end |
#refresh! ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/aws-sdk-core/instance_profile_credentials.rb', line 66 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?
49 50 51 52 |
# File 'lib/aws-sdk-core/instance_profile_credentials.rb', line 49 def secret_access_key refresh_if_stale @secret_access_key end |
#session_token ⇒ String?
55 56 57 58 |
# File 'lib/aws-sdk-core/instance_profile_credentials.rb', line 55 def session_token refresh_if_stale @session_token end |