aws-sdk-core 3.90.0 → 3.93.0

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.
@@ -42,7 +42,7 @@ module Aws
42
42
  option(:unsigned_operations) do |cfg|
43
43
  cfg.api.operation_names.inject([]) do |unsigned, operation_name|
44
44
  if cfg.api.operation(operation_name)['authtype'] == 'none' ||
45
- cfg.api.operation(operation_name)['authtype'] == 'custom'
45
+ cfg.api.operation(operation_name)['authtype'] == 'custom'
46
46
  # Unsign requests that has custom apigateway authorizer as well
47
47
  unsigned << operation_name
48
48
  else
@@ -107,6 +107,17 @@ module Aws
107
107
  req.headers.delete('X-Amz-Security-Token')
108
108
  req.headers.delete('X-Amz-Date')
109
109
 
110
+ if context.config.respond_to?(:clock_skew) &&
111
+ context.config.clock_skew &&
112
+ context.config.correct_clock_skew
113
+
114
+ endpoint = context.http_request.endpoint
115
+ skew = context.config.clock_skew.clock_correction(endpoint)
116
+ if skew.abs > 0
117
+ req.headers['X-Amz-Date'] = (Time.now.utc + skew).strftime("%Y%m%dT%H%M%SZ")
118
+ end
119
+ end
120
+
110
121
  # compute the signature
111
122
  begin
112
123
  signature = signer.sign_request(
@@ -130,7 +141,7 @@ module Aws
130
141
  # @api private
131
142
  def apply_authtype(context)
132
143
  if context.operation['authtype'].eql?('v4-unsigned-body') &&
133
- context.http_request.endpoint.scheme.eql?('https')
144
+ context.http_request.endpoint.scheme.eql?('https')
134
145
  context.http_request.headers['X-Amz-Content-Sha256'] = 'UNSIGNED-PAYLOAD'
135
146
  end
136
147
  context
@@ -34,6 +34,7 @@ requests are made, and retries are disabled.
34
34
  if client.config.stub_responses
35
35
  client.setup_stubbing
36
36
  client.handlers.remove(RetryErrors::Handler)
37
+ client.handlers.remove(RetryErrors::LegacyHandler)
37
38
  client.handlers.remove(ClientMetricsPlugin::Handler)
38
39
  client.handlers.remove(ClientMetricsSendPlugin::LatencyHandler)
39
40
  client.handlers.remove(ClientMetricsSendPlugin::AttemptHandler)
@@ -117,16 +117,18 @@ module Aws
117
117
  credentials
118
118
  end
119
119
 
120
- def assume_role_web_identity_credentials_from_config(profile)
121
- p = profile || @profile_name
120
+ def assume_role_web_identity_credentials_from_config(opts = {})
121
+ p = opts[:profile] || @profile_name
122
122
  if @config_enabled && @parsed_config
123
123
  entry = @parsed_config.fetch(p, {})
124
124
  if entry['web_identity_token_file'] && entry['role_arn']
125
- AssumeRoleWebIdentityCredentials.new(
125
+ cfg = {
126
126
  role_arn: entry['role_arn'],
127
127
  web_identity_token_file: entry['web_identity_token_file'],
128
128
  role_session_name: entry['role_session_name']
129
- )
129
+ }
130
+ cfg[:region] = opts[:region] if opts[:region]
131
+ AssumeRoleWebIdentityCredentials.new(cfg)
130
132
  end
131
133
  end
132
134
  end
@@ -141,16 +143,20 @@ module Aws
141
143
  end
142
144
 
143
145
  config_reader(
146
+ :region,
144
147
  :credential_process,
148
+ :endpoint_discovery_enabled,
149
+ :max_attempts,
150
+ :retry_mode,
151
+ :adaptive_retry_wait_to_fill,
152
+ :correct_clock_skew,
145
153
  :csm_client_id,
146
154
  :csm_enabled,
147
155
  :csm_host,
148
156
  :csm_port,
149
- :endpoint_discovery_enabled,
150
- :region,
157
+ :sts_regional_endpoints,
151
158
  :s3_use_arn_region,
152
- :s3_us_east_1_regional_endpoint,
153
- :sts_regional_endpoints
159
+ :s3_us_east_1_regional_endpoint
154
160
  )
155
161
 
156
162
  private
@@ -182,7 +188,7 @@ module Aws
182
188
  'a credential_source. For assume role credentials, must '\
183
189
  'provide only source_profile or credential_source, not both.'
184
190
  elsif opts[:source_profile]
185
- opts[:credentials] = resolve_source_profile(opts[:source_profile])
191
+ opts[:credentials] = resolve_source_profile(opts[:source_profile], opts)
186
192
  if opts[:credentials]
187
193
  opts[:role_session_name] ||= prof_cfg['role_session_name']
188
194
  opts[:role_session_name] ||= 'default_session'
@@ -220,10 +226,10 @@ module Aws
220
226
  end
221
227
  end
222
228
 
223
- def resolve_source_profile(profile)
229
+ def resolve_source_profile(profile, opts = {})
224
230
  if (creds = credentials(profile: profile))
225
231
  creds # static credentials
226
- elsif (provider = assume_role_web_identity_credentials_from_config(profile))
232
+ elsif (provider = assume_role_web_identity_credentials_from_config(opts.merge(profile: profile)))
227
233
  provider.credentials if provider.credentials.set?
228
234
  elsif (provider = assume_role_process_credentials_from_config(profile))
229
235
  provider.credentials if provider.credentials.set?
@@ -52,6 +52,10 @@ module Aws
52
52
  end
53
53
  end
54
54
 
55
+ def monotonic_seconds
56
+ monotonic_milliseconds / 1000.0
57
+ end
58
+
55
59
  def str_2_bool(str)
56
60
  case str.to_s
57
61
  when "true" then true
@@ -22,17 +22,20 @@ require_relative 'aws-sdk-sts/customizations'
22
22
  # methods each accept a hash of request parameters and return a response
23
23
  # structure.
24
24
  #
25
+ # sts = Aws::STS::Client.new
26
+ # resp = sts.assume_role(params)
27
+ #
25
28
  # See {Client} for more information.
26
29
  #
27
30
  # # Errors
28
31
  #
29
- # Errors returned from AWS Security Token Service all
30
- # extend {Errors::ServiceError}.
32
+ # Errors returned from AWS Security Token Service are defined in the
33
+ # {Errors} module and all extend {Errors::ServiceError}.
31
34
  #
32
35
  # begin
33
36
  # # do stuff
34
37
  # rescue Aws::STS::Errors::ServiceError
35
- # # rescues all service API errors
38
+ # # rescues all AWS Security Token Service API errors
36
39
  # end
37
40
  #
38
41
  # See {Errors} for more information.
@@ -40,6 +43,6 @@ require_relative 'aws-sdk-sts/customizations'
40
43
  # @service
41
44
  module Aws::STS
42
45
 
43
- GEM_VERSION = '3.90.0'
46
+ GEM_VERSION = '3.93.0'
44
47
 
45
48
  end
@@ -31,6 +31,18 @@ require 'aws-sdk-sts/plugins/sts_regional_endpoints.rb'
31
31
  Aws::Plugins::GlobalConfiguration.add_identifier(:sts)
32
32
 
33
33
  module Aws::STS
34
+ # An API client for STS. To construct a client, you need to configure a `:region` and `:credentials`.
35
+ #
36
+ # client = Aws::STS::Client.new(
37
+ # region: region_name,
38
+ # credentials: credentials,
39
+ # # ...
40
+ # )
41
+ #
42
+ # For details on configuring region and credentials see
43
+ # the [developer guide](/sdk-for-ruby/v3/developer-guide/setup-config.html).
44
+ #
45
+ # See {#initialize} for a full list of supported configuration options.
34
46
  class Client < Seahorse::Client::Base
35
47
 
36
48
  include Aws::ClientStubs
@@ -110,6 +122,12 @@ module Aws::STS
110
122
  # When set to `true`, a thread polling for endpoints will be running in
111
123
  # the background every 60 secs (default). Defaults to `false`.
112
124
  #
125
+ # @option options [Boolean] :adaptive_retry_wait_to_fill (true)
126
+ # Used only in `adaptive` retry mode. When true, the request will sleep
127
+ # until there is sufficent client side capacity to retry the request.
128
+ # When false, the request will raise a `RetryCapacityNotAvailableError` and will
129
+ # not retry instead of sleeping.
130
+ #
113
131
  # @option options [Boolean] :client_side_monitoring (false)
114
132
  # When `true`, client-side metrics will be collected for all API requests from
115
133
  # this client.
@@ -134,6 +152,10 @@ module Aws::STS
134
152
  # When `true`, an attempt is made to coerce request parameters into
135
153
  # the required types.
136
154
  #
155
+ # @option options [Boolean] :correct_clock_skew (true)
156
+ # Used only in `standard` and adaptive retry modes. Specifies whether to apply
157
+ # a clock skew correction and retry requests with skewed client clocks.
158
+ #
137
159
  # @option options [Boolean] :disable_host_prefix_injection (false)
138
160
  # Set to true to disable SDK automatically adding host prefix
139
161
  # to default service endpoint when available.
@@ -168,15 +190,29 @@ module Aws::STS
168
190
  # The Logger instance to send log messages to. If this option
169
191
  # is not set, logging will be disabled.
170
192
  #
193
+ # @option options [Integer] :max_attempts (3)
194
+ # An integer representing the maximum number attempts that will be made for
195
+ # a single request, including the initial attempt. For example,
196
+ # setting this value to 5 will result in a request being retried up to
197
+ # 4 times. Used in `standard` and `adaptive` retry modes.
198
+ #
171
199
  # @option options [String] :profile ("default")
172
200
  # Used when loading credentials from the shared credentials file
173
201
  # at HOME/.aws/credentials. When not specified, 'default' is used.
174
202
  #
203
+ # @option options [Proc] :retry_backoff
204
+ # A proc or lambda used for backoff. Defaults to 2**retries * retry_base_delay.
205
+ # This option is only used in the `legacy` retry mode.
206
+ #
175
207
  # @option options [Float] :retry_base_delay (0.3)
176
- # The base delay in seconds used by the default backoff function.
208
+ # The base delay in seconds used by the default backoff function. This option
209
+ # is only used in the `legacy` retry mode.
177
210
  #
178
211
  # @option options [Symbol] :retry_jitter (:none)
179
- # A delay randomiser function used by the default backoff function. Some predefined functions can be referenced by name - :none, :equal, :full, otherwise a Proc that takes and returns a number.
212
+ # A delay randomiser function used by the default backoff function.
213
+ # Some predefined functions can be referenced by name - :none, :equal, :full,
214
+ # otherwise a Proc that takes and returns a number. This option is only used
215
+ # in the `legacy` retry mode.
180
216
  #
181
217
  # @see https://www.awsarchitectureblog.com/2015/03/backoff.html
182
218
  #
@@ -184,20 +220,39 @@ module Aws::STS
184
220
  # The maximum number of times to retry failed requests. Only
185
221
  # ~ 500 level server errors and certain ~ 400 level client errors
186
222
  # are retried. Generally, these are throttling errors, data
187
- # checksum errors, networking errors, timeout errors and auth
188
- # errors from expired credentials.
223
+ # checksum errors, networking errors, timeout errors, auth errors,
224
+ # endpoint discovery, and errors from expired credentials.
225
+ # This option is only used in the `legacy` retry mode.
189
226
  #
190
227
  # @option options [Integer] :retry_max_delay (0)
191
- # The maximum number of seconds to delay between retries (0 for no limit) used by the default backoff function.
228
+ # The maximum number of seconds to delay between retries (0 for no limit)
229
+ # used by the default backoff function. This option is only used in the
230
+ # `legacy` retry mode.
231
+ #
232
+ # @option options [String] :retry_mode ("legacy")
233
+ # Specifies which retry algorithm to use. Values are:
234
+ #
235
+ # * `legacy` - The pre-existing retry behavior. This is default value if
236
+ # no retry mode is provided.
237
+ #
238
+ # * `standard` - A standardized set of retry rules across the AWS SDKs.
239
+ # This includes support for retry quotas, which limit the number of
240
+ # unsuccessful retries a client can make.
241
+ #
242
+ # * `adaptive` - An experimental retry mode that includes all the
243
+ # functionality of `standard` mode along with automatic client side
244
+ # throttling. This is a provisional mode that may change behavior
245
+ # in the future.
246
+ #
192
247
  #
193
248
  # @option options [String] :secret_access_key
194
249
  #
195
250
  # @option options [String] :session_token
196
251
  #
197
- # @option options [String] :sts_regional_endpoints ("legacy")
252
+ # @option options [String] :sts_regional_endpoints ("regional")
198
253
  # Passing in 'regional' to enable regional endpoint for STS for all supported
199
- # regions (except 'aws-global'), defaults to 'legacy' mode, using global endpoint
200
- # for legacy regions.
254
+ # regions (except 'aws-global'). Using 'legacy' mode will force all legacy
255
+ # regions to resolve to the STS global endpoint.
201
256
  #
202
257
  # @option options [Boolean] :stub_responses (false)
203
258
  # Causes the client to return stubbed responses. By default
@@ -216,16 +271,15 @@ module Aws::STS
216
271
  # requests through. Formatted like 'http://proxy.com:123'.
217
272
  #
218
273
  # @option options [Float] :http_open_timeout (15) The number of
219
- # seconds to wait when opening a HTTP session before rasing a
274
+ # seconds to wait when opening a HTTP session before raising a
220
275
  # `Timeout::Error`.
221
276
  #
222
277
  # @option options [Integer] :http_read_timeout (60) The default
223
278
  # number of seconds to wait for response data. This value can
224
- # safely be set
225
- # per-request on the session yeidled by {#session_for}.
279
+ # safely be set per-request on the session.
226
280
  #
227
281
  # @option options [Float] :http_idle_timeout (5) The number of
228
- # seconds a connection is allowed to sit idble before it is
282
+ # seconds a connection is allowed to sit idle before it is
229
283
  # considered stale. Stale connections are closed and removed
230
284
  # from the pool before making a request.
231
285
  #
@@ -234,7 +288,7 @@ module Aws::STS
234
288
  # request body. This option has no effect unless the request has
235
289
  # "Expect" header set to "100-continue". Defaults to `nil` which
236
290
  # disables this behaviour. This value can safely be set per
237
- # request on the session yeidled by {#session_for}.
291
+ # request on the session.
238
292
  #
239
293
  # @option options [Boolean] :http_wire_trace (false) When `true`,
240
294
  # HTTP debug output will be sent to the `:logger`.
@@ -2131,7 +2185,7 @@ module Aws::STS
2131
2185
  params: params,
2132
2186
  config: config)
2133
2187
  context[:gem_name] = 'aws-sdk-core'
2134
- context[:gem_version] = '3.90.0'
2188
+ context[:gem_version] = '3.93.0'
2135
2189
  Seahorse::Client::Request.new(handlers, context)
2136
2190
  end
2137
2191
 
@@ -6,6 +6,36 @@
6
6
  # WARNING ABOUT GENERATED CODE
7
7
 
8
8
  module Aws::STS
9
+
10
+ # When STS returns an error response, the Ruby SDK constructs and raises an error.
11
+ # These errors all extend Aws::STS::Errors::ServiceError < {Aws::Errors::ServiceError}
12
+ #
13
+ # You can rescue all STS errors using ServiceError:
14
+ #
15
+ # begin
16
+ # # do stuff
17
+ # rescue Aws::STS::Errors::ServiceError
18
+ # # rescues all STS API errors
19
+ # end
20
+ #
21
+ #
22
+ # ## Request Context
23
+ # ServiceError objects have a {Aws::Errors::ServiceError#context #context} method that returns
24
+ # information about the request that generated the error.
25
+ # See {Seahorse::Client::RequestContext} for more information.
26
+ #
27
+ # ## Error Classes
28
+ # * {ExpiredTokenException}
29
+ # * {IDPCommunicationErrorException}
30
+ # * {IDPRejectedClaimException}
31
+ # * {InvalidAuthorizationMessageException}
32
+ # * {InvalidIdentityTokenException}
33
+ # * {MalformedPolicyDocumentException}
34
+ # * {PackedPolicyTooLargeException}
35
+ # * {RegionDisabledException}
36
+ #
37
+ # Additionally, error classes are dynamically generated for service errors based on the error code
38
+ # if they are not defined above.
9
39
  module Errors
10
40
 
11
41
  extend Aws::Errors::DynamicErrors
@@ -23,7 +53,6 @@ module Aws::STS
23
53
  def message
24
54
  @message || @data[:message]
25
55
  end
26
-
27
56
  end
28
57
 
29
58
  class IDPCommunicationErrorException < ServiceError
@@ -39,7 +68,6 @@ module Aws::STS
39
68
  def message
40
69
  @message || @data[:message]
41
70
  end
42
-
43
71
  end
44
72
 
45
73
  class IDPRejectedClaimException < ServiceError
@@ -55,7 +83,6 @@ module Aws::STS
55
83
  def message
56
84
  @message || @data[:message]
57
85
  end
58
-
59
86
  end
60
87
 
61
88
  class InvalidAuthorizationMessageException < ServiceError
@@ -71,7 +98,6 @@ module Aws::STS
71
98
  def message
72
99
  @message || @data[:message]
73
100
  end
74
-
75
101
  end
76
102
 
77
103
  class InvalidIdentityTokenException < ServiceError
@@ -87,7 +113,6 @@ module Aws::STS
87
113
  def message
88
114
  @message || @data[:message]
89
115
  end
90
-
91
116
  end
92
117
 
93
118
  class MalformedPolicyDocumentException < ServiceError
@@ -103,7 +128,6 @@ module Aws::STS
103
128
  def message
104
129
  @message || @data[:message]
105
130
  end
106
-
107
131
  end
108
132
 
109
133
  class PackedPolicyTooLargeException < ServiceError
@@ -119,7 +143,6 @@ module Aws::STS
119
143
  def message
120
144
  @message || @data[:message]
121
145
  end
122
-
123
146
  end
124
147
 
125
148
  class RegionDisabledException < ServiceError
@@ -135,7 +158,6 @@ module Aws::STS
135
158
  def message
136
159
  @message || @data[:message]
137
160
  end
138
-
139
161
  end
140
162
 
141
163
  end
@@ -5,12 +5,12 @@ module Aws
5
5
  class STSRegionalEndpoints < Seahorse::Client::Plugin
6
6
 
7
7
  option(:sts_regional_endpoints,
8
- default: 'legacy',
8
+ default: 'regional',
9
9
  doc_type: String,
10
10
  docstring: <<-DOCS) do |cfg|
11
11
  Passing in 'regional' to enable regional endpoint for STS for all supported
12
- regions (except 'aws-global'), defaults to 'legacy' mode, using global endpoint
13
- for legacy regions.
12
+ regions (except 'aws-global'). Using 'legacy' mode will force all legacy
13
+ regions to resolve to the STS global endpoint.
14
14
  DOCS
15
15
  resolve_sts_regional_endpoints(cfg)
16
16
  end
@@ -22,7 +22,7 @@ for legacy regions.
22
22
  env_mode = nil if env_mode == ''
23
23
  cfg_mode = Aws.shared_config.sts_regional_endpoints(
24
24
  profile: cfg.profile)
25
- env_mode || cfg_mode || 'legacy'
25
+ env_mode || cfg_mode || 'regional'
26
26
  end
27
27
 
28
28
  end
@@ -6,6 +6,7 @@
6
6
  # WARNING ABOUT GENERATED CODE
7
7
 
8
8
  module Aws::STS
9
+
9
10
  class Resource
10
11
 
11
12
  # @param options ({})
@@ -3,7 +3,6 @@ require 'delegate'
3
3
  module Seahorse
4
4
  module Client
5
5
  class Response < Delegator
6
-
7
6
  # @option options [RequestContext] :context (nil)
8
7
  # @option options [Integer] :status_code (nil)
9
8
  # @option options [Http::Headers] :headers (Http::Headers.new)
@@ -39,10 +38,10 @@ module Seahorse
39
38
  # witin the given range.
40
39
  #
41
40
  # @return [self]
42
- def on(range, &block)
41
+ def on(range, &_block)
43
42
  response = self
44
43
  @context.http_response.on_success(range) do
45
- block.call(response)
44
+ yield response
46
45
  end
47
46
  self
48
47
  end
@@ -56,7 +55,7 @@ module Seahorse
56
55
  # @return [Boolean] Returns `true` if the response is complete with
57
56
  # a ~ 200 level http status code.
58
57
  def successful?
59
- (200..299).include?(@context.http_response.status_code) && @error.nil?
58
+ (200..299).cover?(@context.http_response.status_code) && @error.nil?
60
59
  end
61
60
 
62
61
  # @api private
@@ -76,7 +75,6 @@ module Seahorse
76
75
  def __setobj__(obj)
77
76
  @data = obj
78
77
  end
79
-
80
78
  end
81
79
  end
82
80
  end