Class: Aws::InstanceProfileCredentials
Overview
An auto-refreshing credential provider that loads credentials from EC2 instances.
instance_credentials = Aws::InstanceProfileCredentials.new
ec2 = Aws::EC2::Client.new(credentials: instance_credentials)
Retries
When initialized from the default credential chain, this provider defaults to 0 retries.
Breakdown of retries is as follows:
- Configurable retries (defaults to
1): these retries handle errors when communicating
with the IMDS endpoint. There are two separate retry mechanisms within the provider:
- Entire token fetch and credential retrieval process
- Token fetching
- JSON parsing retries: Fixed at 3 attempts to handle cases when IMDS returns malformed JSON
responses. These retries are separate from configurable retries.
Constant Summary
RefreshingCredentials::ASYNC_EXPIRATION_LENGTH, RefreshingCredentials::CLIENT_EXCLUDE_OPTIONS, RefreshingCredentials::SYNC_EXPIRATION_LENGTH
Instance Attribute Summary collapse
#credentials, #expiration
Instance Method Summary
collapse
#credentials, #refresh!
#set?
Constructor Details
Returns a new instance of InstanceProfileCredentials.
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
# File 'gems/aws-sdk-core/lib/aws-sdk-core/instance_profile_credentials.rb', line 89
def initialize(options = {})
@backoff = resolve_backoff(options[:backoff])
@disable_imds_v1 = resolve_disable_v1(options)
@endpoint = resolve_endpoint(options)
@http_open_timeout = options[:http_open_timeout] || 1
@http_read_timeout = options[:http_read_timeout] || 1
@http_debug_output = options[:http_debug_output]
@port = options[:port] || 80
@retries = options[:retries] || 1
@token_ttl = options[:token_ttl] || 21_600
@async_refresh = false
@imds_v1_fallback = false
@no_refresh_until = nil
@token = nil
@metrics = ['CREDENTIALS_IMDS']
super
end
|
Instance Attribute Details
#backoff ⇒ Proc
118
119
120
|
# File 'gems/aws-sdk-core/lib/aws-sdk-core/instance_profile_credentials.rb', line 118
def backoff
@backoff
end
|
#disable_imds_v1 ⇒ Boolean
109
110
111
|
# File 'gems/aws-sdk-core/lib/aws-sdk-core/instance_profile_credentials.rb', line 109
def disable_imds_v1
@disable_imds_v1
end
|
#endpoint ⇒ String
121
122
123
|
# File 'gems/aws-sdk-core/lib/aws-sdk-core/instance_profile_credentials.rb', line 121
def endpoint
@endpoint
end
|
#http_debug_output ⇒ IO?
133
134
135
|
# File 'gems/aws-sdk-core/lib/aws-sdk-core/instance_profile_credentials.rb', line 133
def http_debug_output
@http_debug_output
end
|
#http_open_timeout ⇒ Integer
127
128
129
|
# File 'gems/aws-sdk-core/lib/aws-sdk-core/instance_profile_credentials.rb', line 127
def http_open_timeout
@http_open_timeout
end
|
#http_read_timeout ⇒ Integer
130
131
132
|
# File 'gems/aws-sdk-core/lib/aws-sdk-core/instance_profile_credentials.rb', line 130
def http_read_timeout
@http_read_timeout
end
|
#port ⇒ Integer
124
125
126
|
# File 'gems/aws-sdk-core/lib/aws-sdk-core/instance_profile_credentials.rb', line 124
def port
@port
end
|
#retries ⇒ Integer
115
116
117
|
# File 'gems/aws-sdk-core/lib/aws-sdk-core/instance_profile_credentials.rb', line 115
def retries
@retries
end
|
#token_ttl ⇒ Integer
112
113
114
|
# File 'gems/aws-sdk-core/lib/aws-sdk-core/instance_profile_credentials.rb', line 112
def token_ttl
@token_ttl
end
|