aws-sdk-core 3.128.0 → 3.129.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1cf93a52549a583ebf666ac76c7c9243e3068ff7c3e2bd18051ed14d6b2dda36
4
- data.tar.gz: c5dd331a95e8437164d33537b0e415de2d74dacc596f2e7675124bd1afded021
3
+ metadata.gz: 49ca96451c7816e538a74ba800cbc2ade4fcfb7a9d712fea2cc6da12deca1172
4
+ data.tar.gz: 12431a75db151e6c918707c1e592a1810849eebdc437cc41564cb06d536227fc
5
5
  SHA512:
6
- metadata.gz: 4b35894b76ba7531148db72002bbad246a2617a8ec412426520002ef10f82e91b7b89d0cb99cea33b2123a9a7641c98cf4d97769cbccd8c6e6f7bbf5ae4fbb98
7
- data.tar.gz: e0818ff963cf8f516a741348d625099c4f3a1d70ad5f30a8722a152f77e251d08a5411eae07a5840b718d636d0eb486a2ea59c6f968d0550bf4e230564baa763
6
+ metadata.gz: 6f59af7600dc1f0e76566543cadf66b65f838c195d0a24c962043cf38cbbb190ee5be73daa968acbe332dd9490d9fadd89882e3a6d87f60c2f6f8ef1150f382d
7
+ data.tar.gz: 56baca1bd31275d8aa749890f0fe02d0e02b6d01df8c9596573efc3c269e6145bfaedbb813ae0aa03982dbc7ea2d35f9a84e58a9b3323304d78e70aab18b0947
data/CHANGELOG.md CHANGED
@@ -1,6 +1,21 @@
1
1
  Unreleased Changes
2
2
  ------------------
3
3
 
4
+ 3.129.1 (2022-03-10)
5
+ ------------------
6
+
7
+ * Issue - Make stubs thread safe by creating new responses for each operation call (#2675).
8
+
9
+ 3.129.0 (2022-03-08)
10
+ ------------------
11
+
12
+ * Feature - Add support for cases when `InstanceProfileCredentials` (IMDS) is unable to refresh credentials.
13
+
14
+ 3.128.1 (2022-03-07)
15
+ ------------------
16
+
17
+ * Issue - Fixed `Aws::PageableResponse` invalidating Ruby's global constant cache.
18
+
4
19
  3.128.0 (2022-03-04)
5
20
  ------------------
6
21
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.128.0
1
+ 3.129.1
@@ -262,13 +262,17 @@ module Aws
262
262
  end
263
263
 
264
264
  def convert_stub(operation_name, stub)
265
- case stub
265
+ stub = case stub
266
266
  when Proc then stub
267
267
  when Exception, Class then { error: stub }
268
268
  when String then service_error_stub(stub)
269
269
  when Hash then http_response_stub(operation_name, stub)
270
270
  else { data: stub }
271
271
  end
272
+ if Hash === stub
273
+ stub[:mutex] = Mutex.new
274
+ end
275
+ stub
272
276
  end
273
277
 
274
278
  def service_error_stub(error_code)
@@ -78,6 +78,7 @@ module Aws
78
78
  @backoff = backoff(options[:backoff])
79
79
  @token_ttl = options[:token_ttl] || 21_600
80
80
  @token = nil
81
+ @no_refresh_until = nil
81
82
  super
82
83
  end
83
84
 
@@ -125,18 +126,48 @@ module Aws
125
126
  end
126
127
 
127
128
  def refresh
129
+ if @no_refresh_until && @no_refresh_until > Time.now
130
+ warn_expired_credentials
131
+ return
132
+ end
133
+
128
134
  # Retry loading credentials up to 3 times is the instance metadata
129
135
  # service is responding but is returning invalid JSON documents
130
136
  # in response to the GET profile credentials call.
131
137
  begin
132
138
  retry_errors([Aws::Json::ParseError, StandardError], max_retries: 3) do
133
139
  c = Aws::Json.load(get_credentials.to_s)
134
- @credentials = Credentials.new(
135
- c['AccessKeyId'],
136
- c['SecretAccessKey'],
137
- c['Token']
138
- )
139
- @expiration = c['Expiration'] ? Time.iso8601(c['Expiration']) : nil
140
+ if empty_credentials?(@credentials)
141
+ @credentials = Credentials.new(
142
+ c['AccessKeyId'],
143
+ c['SecretAccessKey'],
144
+ c['Token']
145
+ )
146
+ @expiration = c['Expiration'] ? Time.iso8601(c['Expiration']) : nil
147
+ if @expiration && @expiration < Time.now
148
+ @no_refresh_until = Time.now + refresh_offset
149
+ warn_expired_credentials
150
+ end
151
+ else
152
+ # credentials are already set, update them only if the new ones are not empty
153
+ if !c['AccessKeyId'] || c['AccessKeyId'].empty?
154
+ # error getting new credentials
155
+ @no_refresh_until = Time.now + refresh_offset
156
+ warn_expired_credentials
157
+ else
158
+ @credentials = Credentials.new(
159
+ c['AccessKeyId'],
160
+ c['SecretAccessKey'],
161
+ c['Token']
162
+ )
163
+ @expiration = c['Expiration'] ? Time.iso8601(c['Expiration']) : nil
164
+ if @expiration && @expiration < Time.now
165
+ @no_refresh_until = Time.now + refresh_offset
166
+ warn_expired_credentials
167
+ end
168
+ end
169
+ end
170
+
140
171
  end
141
172
  rescue Aws::Json::ParseError
142
173
  raise Aws::Errors::MetadataParserError
@@ -260,6 +291,21 @@ module Aws
260
291
  end
261
292
  end
262
293
 
294
+ def warn_expired_credentials
295
+ warn("Attempting credential expiration extension due to a credential "\
296
+ "service availability issue. A refresh of these credentials "\
297
+ "will be attempted again in 5 minutes.")
298
+ end
299
+
300
+ def empty_credentials?(creds)
301
+ !creds || !creds.access_key_id || creds.access_key_id.empty?
302
+ end
303
+
304
+ # Compute an offset for refresh with jitter
305
+ def refresh_offset
306
+ 300 + rand(0..60)
307
+ end
308
+
263
309
  # @api private
264
310
  # Token used to fetch IMDS profile and credentials
265
311
  class Token
@@ -48,11 +48,11 @@ module Aws
48
48
  #
49
49
  module PageableResponse
50
50
 
51
- def self.extended(base)
52
- base.extend Enumerable
53
- base.extend UnsafeEnumerableMethods
54
- base.instance_variable_set("@last_page", nil)
55
- base.instance_variable_set("@more_results", nil)
51
+ def self.apply(base)
52
+ base.extend Extension
53
+ base.instance_variable_set(:@last_page, nil)
54
+ base.instance_variable_set(:@more_results, nil)
55
+ base
56
56
  end
57
57
 
58
58
  # @return [Paging::Pager]
@@ -62,39 +62,26 @@ module Aws
62
62
  # when this method returns `false` will raise an error.
63
63
  # @return [Boolean]
64
64
  def last_page?
65
- if @last_page.nil?
66
- @last_page = !@pager.truncated?(self)
67
- end
68
- @last_page
65
+ # Actual implementation is in PageableResponse::Extension
69
66
  end
70
67
 
71
68
  # Returns `true` if there are more results. Calling {#next_page} will
72
69
  # return the next response.
73
70
  # @return [Boolean]
74
71
  def next_page?
75
- !last_page?
72
+ # Actual implementation is in PageableResponse::Extension
76
73
  end
77
74
 
78
75
  # @return [Seahorse::Client::Response]
79
76
  def next_page(params = {})
80
- if last_page?
81
- raise LastPageError.new(self)
82
- else
83
- next_response(params)
84
- end
77
+ # Actual implementation is in PageableResponse::Extension
85
78
  end
86
79
 
87
80
  # Yields the current and each following response to the given block.
88
81
  # @yieldparam [Response] response
89
82
  # @return [Enumerable,nil] Returns a new Enumerable if no block is given.
90
83
  def each(&block)
91
- return enum_for(:each_page) unless block_given?
92
- response = self
93
- yield(response)
94
- until response.last_page?
95
- response = response.next_page
96
- yield(response)
97
- end
84
+ # Actual implementation is in PageableResponse::Extension
98
85
  end
99
86
  alias each_page each
100
87
 
@@ -105,9 +92,7 @@ module Aws
105
92
  # @return [Seahorse::Client::Response] Returns the next page of
106
93
  # results.
107
94
  def next_response(params)
108
- params = next_page_params(params)
109
- request = context.client.build_request(context.operation_name, params)
110
- request.send_request
95
+ # Actual implementation is in PageableResponse::Extension
111
96
  end
112
97
 
113
98
  # @param [Hash] params A hash of additional request params to
@@ -115,13 +100,7 @@ module Aws
115
100
  # @return [Hash] Returns the hash of request parameters for the
116
101
  # next page, merging any given params.
117
102
  def next_page_params(params)
118
- # Remove all previous tokens from original params
119
- # Sometimes a token can be nil and merge would not include it.
120
- tokens = @pager.tokens.values.map(&:to_sym)
121
-
122
- params_without_tokens = context[:original_params].reject { |k, _v| tokens.include?(k) }
123
- params_without_tokens.merge!(@pager.next_tokens(self).merge(params))
124
- params_without_tokens
103
+ # Actual implementation is in PageableResponse::Extension
125
104
  end
126
105
 
127
106
  # Raised when calling {PageableResponse#next_page} on a pager that
@@ -168,5 +147,66 @@ module Aws
168
147
  end
169
148
 
170
149
  end
150
+
151
+ # The actual decorator module implementation. It is in a distinct module
152
+ # so that it can be used to extend objects without busting Ruby's constant cache.
153
+ # object.extend(mod) bust the constant cache only if `mod` contains constants of its own.
154
+ # @api private
155
+ module Extension
156
+
157
+ include Enumerable
158
+ include UnsafeEnumerableMethods
159
+
160
+ attr_accessor :pager
161
+
162
+ def last_page?
163
+ if @last_page.nil?
164
+ @last_page = !@pager.truncated?(self)
165
+ end
166
+ @last_page
167
+ end
168
+
169
+ def next_page?
170
+ !last_page?
171
+ end
172
+
173
+ def next_page(params = {})
174
+ if last_page?
175
+ raise LastPageError.new(self)
176
+ else
177
+ next_response(params)
178
+ end
179
+ end
180
+
181
+ def each(&block)
182
+ return enum_for(:each_page) unless block_given?
183
+ response = self
184
+ yield(response)
185
+ until response.last_page?
186
+ response = response.next_page
187
+ yield(response)
188
+ end
189
+ end
190
+ alias each_page each
191
+
192
+ private
193
+
194
+ def next_response(params)
195
+ params = next_page_params(params)
196
+ request = context.client.build_request(context.operation_name, params)
197
+ request.send_request
198
+ end
199
+
200
+ def next_page_params(params)
201
+ # Remove all previous tokens from original params
202
+ # Sometimes a token can be nil and merge would not include it.
203
+ tokens = @pager.tokens.values.map(&:to_sym)
204
+
205
+ params_without_tokens = context[:original_params].reject { |k, _v| tokens.include?(k) }
206
+ params_without_tokens.merge!(@pager.next_tokens(self).merge(params))
207
+ params_without_tokens
208
+ end
209
+
210
+ end
171
211
  end
172
212
  end
@@ -10,7 +10,7 @@ module Aws
10
10
  def call(context)
11
11
  context[:original_params] = context.params
12
12
  resp = @handler.call(context)
13
- resp.extend(PageableResponse)
13
+ PageableResponse.apply(resp)
14
14
  resp.pager = context.operation[:pager] || Aws::Pager::NullPager.new
15
15
  resp
16
16
  end
@@ -51,7 +51,11 @@ requests are made, and retries are disabled.
51
51
  stub = context.client.next_stub(context)
52
52
  resp = Seahorse::Client::Response.new(context: context)
53
53
  async_mode = context.client.is_a? Seahorse::Client::AsyncBase
54
- apply_stub(stub, resp, async_mode)
54
+ if Hash === stub && stub[:mutex]
55
+ stub[:mutex].synchronize { apply_stub(stub, resp, async_mode) }
56
+ else
57
+ apply_stub(stub, resp, async_mode)
58
+ end
55
59
 
56
60
  async_mode ? Seahorse::Client::AsyncResponse.new(
57
61
  context: context, stream: context[:input_event_stream_handler].event_emitter.stream, sync_queue: Queue.new) : resp
@@ -545,7 +545,7 @@ module Aws::SSO
545
545
  params: params,
546
546
  config: config)
547
547
  context[:gem_name] = 'aws-sdk-core'
548
- context[:gem_version] = '3.128.0'
548
+ context[:gem_version] = '3.129.1'
549
549
  Seahorse::Client::Request.new(handlers, context)
550
550
  end
551
551
 
data/lib/aws-sdk-sso.rb CHANGED
@@ -50,6 +50,6 @@ require_relative 'aws-sdk-sso/customizations'
50
50
  # @!group service
51
51
  module Aws::SSO
52
52
 
53
- GEM_VERSION = '3.128.0'
53
+ GEM_VERSION = '3.129.1'
54
54
 
55
55
  end
@@ -2290,7 +2290,7 @@ module Aws::STS
2290
2290
  params: params,
2291
2291
  config: config)
2292
2292
  context[:gem_name] = 'aws-sdk-core'
2293
- context[:gem_version] = '3.128.0'
2293
+ context[:gem_version] = '3.129.1'
2294
2294
  Seahorse::Client::Request.new(handlers, context)
2295
2295
  end
2296
2296
 
data/lib/aws-sdk-sts.rb CHANGED
@@ -50,6 +50,6 @@ require_relative 'aws-sdk-sts/customizations'
50
50
  # @!group service
51
51
  module Aws::STS
52
52
 
53
- GEM_VERSION = '3.128.0'
53
+ GEM_VERSION = '3.129.1'
54
54
 
55
55
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-sdk-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.128.0
4
+ version: 3.129.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amazon Web Services
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-04 00:00:00.000000000 Z
11
+ date: 2022-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jmespath