Class: AWS::Core::CredentialProviders::EC2Provider
- Inherits:
-
Object
- Object
- AWS::Core::CredentialProviders::EC2Provider
- Includes:
- Provider
- Defined in:
- lib/aws/core/credential_providers.rb
Overview
This credential provider tries to get credentials from the EC2 metadata service.
Constant Summary
Constants included from Provider
Instance Attribute Summary collapse
- #credentials_expiration ⇒ Time?
- #http_debug_output ⇒ Object?
- #http_open_timeout ⇒ Float
- #http_read_timeout ⇒ Float
-
#ip_address ⇒ String
Defaults to ‘169.254.169.254’.
-
#port ⇒ Integer
Defaults to port 80.
Instance Method Summary collapse
-
#credentials ⇒ Hash
Refresh provider if existing credentials will be expired in 5 min.
-
#initialize(options = {}) ⇒ EC2Provider
constructor
A new instance of EC2Provider.
Methods included from Provider
#access_key_id, #refresh, #secret_access_key, #session_token
Constructor Details
#initialize(options = {}) ⇒ EC2Provider
Returns a new instance of EC2Provider.
236 237 238 239 240 241 242 |
# File 'lib/aws/core/credential_providers.rb', line 236 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] end |
Instance Attribute Details
#credentials_expiration ⇒ Time?
260 261 262 |
# File 'lib/aws/core/credential_providers.rb', line 260 def credentials_expiration @credentials_expiration end |
#http_debug_output ⇒ Object?
257 258 259 |
# File 'lib/aws/core/credential_providers.rb', line 257 def http_debug_output @http_debug_output end |
#http_open_timeout ⇒ Float
251 252 253 |
# File 'lib/aws/core/credential_providers.rb', line 251 def http_open_timeout @http_open_timeout end |
#http_read_timeout ⇒ Float
254 255 256 |
# File 'lib/aws/core/credential_providers.rb', line 254 def http_read_timeout @http_read_timeout end |
#ip_address ⇒ String
Returns Defaults to ‘169.254.169.254’.
245 246 247 |
# File 'lib/aws/core/credential_providers.rb', line 245 def ip_address @ip_address end |
#port ⇒ Integer
Returns Defaults to port 80.
248 249 250 |
# File 'lib/aws/core/credential_providers.rb', line 248 def port @port end |
Instance Method Details
#credentials ⇒ Hash
Refresh provider if existing credentials will be expired in 5 min
270 271 272 273 274 275 |
# File 'lib/aws/core/credential_providers.rb', line 270 def credentials if @credentials_expiration && @credentials_expiration.utc <= Time.now.utc - 5 * 60 refresh end super end |