aws-sdk-core 3.173.0 → 3.254.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.
Files changed (213) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +947 -0
  3. data/VERSION +1 -1
  4. data/lib/aws-defaults/default_configuration.rb +5 -6
  5. data/lib/aws-defaults.rb +4 -1
  6. data/lib/aws-sdk-core/arn.rb +1 -3
  7. data/lib/aws-sdk-core/assume_role_credentials.rb +21 -13
  8. data/lib/aws-sdk-core/assume_role_web_identity_credentials.rb +16 -9
  9. data/lib/aws-sdk-core/binary/decode_handler.rb +3 -9
  10. data/lib/aws-sdk-core/binary/encode_handler.rb +1 -1
  11. data/lib/aws-sdk-core/binary/event_builder.rb +34 -37
  12. data/lib/aws-sdk-core/binary/event_stream_decoder.rb +1 -0
  13. data/lib/aws-sdk-core/binary/event_stream_encoder.rb +4 -3
  14. data/lib/aws-sdk-core/cbor/decoder.rb +309 -0
  15. data/lib/aws-sdk-core/cbor/encoder.rb +243 -0
  16. data/lib/aws-sdk-core/cbor.rb +53 -0
  17. data/lib/aws-sdk-core/client_side_monitoring.rb +9 -0
  18. data/lib/aws-sdk-core/client_stubs.rb +39 -55
  19. data/lib/aws-sdk-core/credential_provider.rb +8 -1
  20. data/lib/aws-sdk-core/credential_provider_chain.rb +101 -25
  21. data/lib/aws-sdk-core/credentials.rb +19 -6
  22. data/lib/aws-sdk-core/ec2_metadata.rb +1 -1
  23. data/lib/aws-sdk-core/ecs_credentials.rb +104 -26
  24. data/lib/aws-sdk-core/endpoints/endpoint.rb +3 -1
  25. data/lib/aws-sdk-core/endpoints/matchers.rb +21 -19
  26. data/lib/aws-sdk-core/endpoints.rb +106 -22
  27. data/lib/aws-sdk-core/error_handler.rb +46 -0
  28. data/lib/aws-sdk-core/errors.rb +17 -5
  29. data/lib/aws-sdk-core/event_emitter.rb +1 -17
  30. data/lib/aws-sdk-core/ini_parser.rb +7 -0
  31. data/lib/aws-sdk-core/instance_profile_credentials.rb +181 -158
  32. data/lib/aws-sdk-core/json/builder.rb +23 -1
  33. data/lib/aws-sdk-core/json/error_handler.rb +31 -14
  34. data/lib/aws-sdk-core/json/handler.rb +13 -6
  35. data/lib/aws-sdk-core/json/json_engine.rb +3 -1
  36. data/lib/aws-sdk-core/json/oj_engine.rb +7 -1
  37. data/lib/aws-sdk-core/json/parser.rb +33 -3
  38. data/lib/aws-sdk-core/json.rb +43 -14
  39. data/lib/aws-sdk-core/log/param_filter.rb +2 -2
  40. data/lib/aws-sdk-core/log/param_formatter.rb +7 -3
  41. data/lib/aws-sdk-core/log.rb +10 -0
  42. data/lib/aws-sdk-core/login_credentials.rb +230 -0
  43. data/lib/aws-sdk-core/lru_cache.rb +75 -0
  44. data/lib/aws-sdk-core/pageable_response.rb +3 -1
  45. data/lib/aws-sdk-core/param_validator.rb +9 -4
  46. data/lib/aws-sdk-core/plugins/bearer_authorization.rb +2 -0
  47. data/lib/aws-sdk-core/plugins/checksum_algorithm.rb +437 -201
  48. data/lib/aws-sdk-core/plugins/client_metrics_plugin.rb +1 -1
  49. data/lib/aws-sdk-core/plugins/client_metrics_send_plugin.rb +14 -2
  50. data/lib/aws-sdk-core/plugins/credentials_configuration.rb +78 -56
  51. data/lib/aws-sdk-core/plugins/endpoint_pattern.rb +40 -32
  52. data/lib/aws-sdk-core/plugins/global_configuration.rb +8 -9
  53. data/lib/aws-sdk-core/plugins/http_checksum.rb +3 -8
  54. data/lib/aws-sdk-core/plugins/invocation_id.rb +1 -11
  55. data/lib/aws-sdk-core/plugins/logging.rb +2 -0
  56. data/lib/aws-sdk-core/plugins/protocols/api_gateway.rb +3 -1
  57. data/lib/aws-sdk-core/plugins/protocols/ec2.rb +2 -24
  58. data/lib/aws-sdk-core/plugins/protocols/json_rpc.rb +6 -8
  59. data/lib/aws-sdk-core/plugins/protocols/query.rb +4 -2
  60. data/lib/aws-sdk-core/plugins/protocols/rest_json.rb +3 -15
  61. data/lib/aws-sdk-core/plugins/protocols/rest_xml.rb +3 -0
  62. data/lib/aws-sdk-core/plugins/protocols/rpc_v2.rb +17 -0
  63. data/lib/aws-sdk-core/plugins/regional_endpoint.rb +162 -37
  64. data/lib/aws-sdk-core/plugins/request_compression.rb +226 -0
  65. data/lib/aws-sdk-core/plugins/retries/clock_skew.rb +28 -16
  66. data/lib/aws-sdk-core/plugins/retries/retry_quota.rb +11 -8
  67. data/lib/aws-sdk-core/plugins/retry_errors.rb +211 -110
  68. data/lib/aws-sdk-core/plugins/sign.rb +55 -33
  69. data/lib/aws-sdk-core/plugins/signature_v2.rb +2 -1
  70. data/lib/aws-sdk-core/plugins/signature_v4.rb +2 -1
  71. data/lib/aws-sdk-core/plugins/stub_responses.rb +59 -9
  72. data/lib/aws-sdk-core/plugins/telemetry.rb +75 -0
  73. data/lib/aws-sdk-core/plugins/transfer_encoding.rb +16 -9
  74. data/lib/aws-sdk-core/plugins/user_agent.rb +205 -14
  75. data/lib/aws-sdk-core/plugins.rb +39 -0
  76. data/lib/aws-sdk-core/process_credentials.rb +48 -29
  77. data/lib/aws-sdk-core/query/ec2_handler.rb +27 -0
  78. data/lib/aws-sdk-core/query/ec2_param_builder.rb +5 -7
  79. data/lib/aws-sdk-core/query/handler.rb +4 -4
  80. data/lib/aws-sdk-core/query/param_builder.rb +2 -2
  81. data/lib/aws-sdk-core/query.rb +2 -1
  82. data/lib/aws-sdk-core/refreshing_credentials.rb +20 -23
  83. data/lib/aws-sdk-core/resources.rb +8 -0
  84. data/lib/aws-sdk-core/rest/content_type_handler.rb +60 -0
  85. data/lib/aws-sdk-core/rest/handler.rb +3 -4
  86. data/lib/aws-sdk-core/rest/request/body.rb +32 -5
  87. data/lib/aws-sdk-core/rest/request/endpoint.rb +24 -4
  88. data/lib/aws-sdk-core/rest/request/headers.rb +15 -7
  89. data/lib/aws-sdk-core/rest/request/querystring_builder.rb +62 -36
  90. data/lib/aws-sdk-core/rest/response/body.rb +15 -1
  91. data/lib/aws-sdk-core/rest/response/header_list_parser.rb +79 -0
  92. data/lib/aws-sdk-core/rest/response/headers.rb +8 -3
  93. data/lib/aws-sdk-core/rest.rb +1 -0
  94. data/lib/aws-sdk-core/rpc_v2/builder.rb +62 -0
  95. data/lib/aws-sdk-core/rpc_v2/cbor_engine.rb +18 -0
  96. data/lib/aws-sdk-core/rpc_v2/content_type_handler.rb +47 -0
  97. data/lib/aws-sdk-core/rpc_v2/error_handler.rb +95 -0
  98. data/lib/aws-sdk-core/rpc_v2/handler.rb +79 -0
  99. data/lib/aws-sdk-core/rpc_v2/parser.rb +98 -0
  100. data/lib/aws-sdk-core/rpc_v2.rb +69 -0
  101. data/lib/aws-sdk-core/shared_config.rb +155 -39
  102. data/lib/aws-sdk-core/shared_credentials.rb +1 -7
  103. data/lib/aws-sdk-core/sso_credentials.rb +6 -3
  104. data/lib/aws-sdk-core/sso_token_provider.rb +1 -0
  105. data/lib/aws-sdk-core/static_token_provider.rb +1 -2
  106. data/lib/aws-sdk-core/stubbing/protocols/ec2.rb +12 -11
  107. data/lib/aws-sdk-core/stubbing/protocols/json.rb +11 -10
  108. data/lib/aws-sdk-core/stubbing/protocols/query.rb +7 -6
  109. data/lib/aws-sdk-core/stubbing/protocols/rest.rb +2 -1
  110. data/lib/aws-sdk-core/stubbing/protocols/rest_json.rb +9 -8
  111. data/lib/aws-sdk-core/stubbing/protocols/rest_xml.rb +6 -5
  112. data/lib/aws-sdk-core/stubbing/protocols/rpc_v2.rb +39 -0
  113. data/lib/aws-sdk-core/stubbing/stub_data.rb +11 -0
  114. data/lib/aws-sdk-core/stubbing.rb +22 -0
  115. data/lib/aws-sdk-core/telemetry/base.rb +177 -0
  116. data/lib/aws-sdk-core/telemetry/no_op.rb +70 -0
  117. data/lib/aws-sdk-core/telemetry/otel.rb +235 -0
  118. data/lib/aws-sdk-core/telemetry/span_kind.rb +22 -0
  119. data/lib/aws-sdk-core/telemetry/span_status.rb +59 -0
  120. data/lib/aws-sdk-core/telemetry.rb +78 -0
  121. data/lib/aws-sdk-core/token.rb +3 -3
  122. data/lib/aws-sdk-core/token_provider.rb +4 -0
  123. data/lib/aws-sdk-core/token_provider_chain.rb +2 -6
  124. data/lib/aws-sdk-core/util.rb +41 -1
  125. data/lib/aws-sdk-core/waiters/poller.rb +12 -5
  126. data/lib/aws-sdk-core/xml/builder.rb +17 -9
  127. data/lib/aws-sdk-core/xml/error_handler.rb +35 -43
  128. data/lib/aws-sdk-core/xml/parser/frame.rb +4 -20
  129. data/lib/aws-sdk-core/xml/parser/stack.rb +2 -0
  130. data/lib/aws-sdk-core/xml/parser.rb +2 -6
  131. data/lib/aws-sdk-core.rb +86 -107
  132. data/lib/aws-sdk-signin/client.rb +1008 -0
  133. data/lib/aws-sdk-signin/client_api.rb +444 -0
  134. data/lib/aws-sdk-signin/customizations.rb +1 -0
  135. data/lib/aws-sdk-signin/endpoint_parameters.rb +85 -0
  136. data/lib/aws-sdk-signin/endpoint_provider.rb +107 -0
  137. data/lib/aws-sdk-signin/endpoints.rb +133 -0
  138. data/lib/aws-sdk-signin/errors.rb +185 -0
  139. data/lib/aws-sdk-signin/plugins/endpoints.rb +77 -0
  140. data/lib/aws-sdk-signin/resource.rb +26 -0
  141. data/lib/aws-sdk-signin/types.rb +909 -0
  142. data/lib/aws-sdk-signin.rb +63 -0
  143. data/lib/aws-sdk-sso/client.rb +210 -99
  144. data/lib/aws-sdk-sso/client_api.rb +7 -0
  145. data/lib/aws-sdk-sso/endpoint_parameters.rb +13 -10
  146. data/lib/aws-sdk-sso/endpoint_provider.rb +30 -28
  147. data/lib/aws-sdk-sso/endpoints.rb +3 -54
  148. data/lib/aws-sdk-sso/plugins/endpoints.rb +23 -22
  149. data/lib/aws-sdk-sso/types.rb +1 -0
  150. data/lib/aws-sdk-sso.rb +15 -11
  151. data/lib/aws-sdk-ssooidc/client.rb +630 -132
  152. data/lib/aws-sdk-ssooidc/client_api.rb +94 -1
  153. data/lib/aws-sdk-ssooidc/endpoint_parameters.rb +13 -10
  154. data/lib/aws-sdk-ssooidc/endpoint_provider.rb +30 -28
  155. data/lib/aws-sdk-ssooidc/endpoints.rb +3 -40
  156. data/lib/aws-sdk-ssooidc/errors.rb +62 -0
  157. data/lib/aws-sdk-ssooidc/plugins/endpoints.rb +23 -20
  158. data/lib/aws-sdk-ssooidc/types.rb +419 -53
  159. data/lib/aws-sdk-ssooidc.rb +15 -11
  160. data/lib/aws-sdk-sts/client.rb +567 -158
  161. data/lib/aws-sdk-sts/client_api.rb +120 -9
  162. data/lib/aws-sdk-sts/customizations.rb +5 -2
  163. data/lib/aws-sdk-sts/endpoint_parameters.rb +15 -14
  164. data/lib/aws-sdk-sts/endpoint_provider.rb +52 -57
  165. data/lib/aws-sdk-sts/endpoints.rb +3 -118
  166. data/lib/aws-sdk-sts/errors.rb +79 -0
  167. data/lib/aws-sdk-sts/plugins/endpoints.rb +23 -30
  168. data/lib/aws-sdk-sts/presigner.rb +3 -7
  169. data/lib/aws-sdk-sts/types.rb +382 -31
  170. data/lib/aws-sdk-sts.rb +15 -11
  171. data/lib/seahorse/client/async_base.rb +4 -5
  172. data/lib/seahorse/client/async_response.rb +19 -0
  173. data/lib/seahorse/client/base.rb +18 -21
  174. data/lib/seahorse/client/configuration.rb +0 -4
  175. data/lib/seahorse/client/h2/connection.rb +18 -28
  176. data/lib/seahorse/client/h2/handler.rb +19 -3
  177. data/lib/seahorse/client/handler.rb +1 -1
  178. data/lib/seahorse/client/http/response.rb +1 -1
  179. data/lib/seahorse/client/net_http/connection_pool.rb +15 -12
  180. data/lib/seahorse/client/net_http/handler.rb +21 -9
  181. data/lib/seahorse/client/net_http/patches.rb +44 -14
  182. data/lib/seahorse/client/networking_error.rb +1 -1
  183. data/lib/seahorse/client/plugin.rb +9 -0
  184. data/lib/seahorse/client/plugins/endpoint.rb +0 -1
  185. data/lib/seahorse/client/plugins/h2.rb +4 -4
  186. data/lib/seahorse/client/plugins/net_http.rb +57 -16
  187. data/lib/seahorse/client/plugins/request_callback.rb +31 -0
  188. data/lib/seahorse/client/request_context.rb +9 -2
  189. data/lib/seahorse/client/response.rb +8 -0
  190. data/lib/seahorse/model/operation.rb +3 -0
  191. data/lib/seahorse/model/shapes.rb +2 -2
  192. data/lib/seahorse/util.rb +2 -1
  193. data/sig/aws-sdk-core/async_client_stubs.rbs +21 -0
  194. data/sig/aws-sdk-core/client_stubs.rbs +10 -0
  195. data/sig/aws-sdk-core/errors.rbs +22 -0
  196. data/sig/aws-sdk-core/resources/collection.rbs +21 -0
  197. data/sig/aws-sdk-core/structure.rbs +4 -0
  198. data/sig/aws-sdk-core/telemetry/base.rbs +46 -0
  199. data/sig/aws-sdk-core/telemetry/otel.rbs +22 -0
  200. data/sig/aws-sdk-core/telemetry/span_kind.rbs +15 -0
  201. data/sig/aws-sdk-core/telemetry/span_status.rbs +24 -0
  202. data/sig/aws-sdk-core/waiters/errors.rbs +20 -0
  203. data/sig/aws-sdk-core.rbs +7 -0
  204. data/sig/seahorse/client/async_base.rbs +18 -0
  205. data/sig/seahorse/client/base.rbs +25 -0
  206. data/sig/seahorse/client/handler_builder.rbs +16 -0
  207. data/sig/seahorse/client/response.rbs +61 -0
  208. metadata +118 -23
  209. /data/lib/aws-sdk-core/xml/parser/{engines/libxml.rb → libxml_engine.rb} +0 -0
  210. /data/lib/aws-sdk-core/xml/parser/{engines/nokogiri.rb → nokogiri_engine.rb} +0 -0
  211. /data/lib/aws-sdk-core/xml/parser/{engines/oga.rb → oga_engine.rb} +0 -0
  212. /data/lib/aws-sdk-core/xml/parser/{engines/ox.rb → ox_engine.rb} +0 -0
  213. /data/lib/aws-sdk-core/xml/parser/{engines/rexml.rb → rexml_engine.rb} +0 -0
@@ -41,77 +41,76 @@ module Aws
41
41
  :retry_limit,
42
42
  default: 3,
43
43
  doc_type: Integer,
44
- docstring: <<-DOCS)
45
- The maximum number of times to retry failed requests. Only
46
- ~ 500 level server errors and certain ~ 400 level client errors
47
- are retried. Generally, these are throttling errors, data
48
- checksum errors, networking errors, timeout errors, auth errors,
49
- endpoint discovery, and errors from expired credentials.
50
- This option is only used in the `legacy` retry mode.
44
+ docstring: <<~DOCS)
45
+ The maximum number of times to retry failed requests. Only
46
+ ~ 500 level server errors and certain ~ 400 level client errors
47
+ are retried. Generally, these are throttling errors, data
48
+ checksum errors, networking errors, timeout errors, auth errors,
49
+ endpoint discovery, and errors from expired credentials.
50
+ This option is only used in the `legacy` retry mode.
51
51
  DOCS
52
52
 
53
53
  option(
54
54
  :retry_max_delay,
55
55
  default: 0,
56
56
  doc_type: Integer,
57
- docstring: <<-DOCS)
58
- The maximum number of seconds to delay between retries (0 for no limit)
59
- used by the default backoff function. This option is only used in the
60
- `legacy` retry mode.
57
+ docstring: <<~DOCS)
58
+ The maximum number of seconds to delay between retries (0 for no limit)
59
+ used by the default backoff function. This option is only used in the
60
+ `legacy` retry mode.
61
61
  DOCS
62
62
 
63
63
  option(
64
64
  :retry_base_delay,
65
65
  default: 0.3,
66
66
  doc_type: Float,
67
- docstring: <<-DOCS)
68
- The base delay in seconds used by the default backoff function. This option
69
- is only used in the `legacy` retry mode.
67
+ docstring: <<~DOCS)
68
+ The base delay in seconds used by the default backoff function. This option
69
+ is only used in the `legacy` retry mode.
70
70
  DOCS
71
71
 
72
72
  option(
73
73
  :retry_jitter,
74
74
  default: :none,
75
75
  doc_type: Symbol,
76
- docstring: <<-DOCS)
77
- A delay randomiser function used by the default backoff function.
78
- Some predefined functions can be referenced by name - :none, :equal, :full,
79
- otherwise a Proc that takes and returns a number. This option is only used
80
- in the `legacy` retry mode.
81
-
82
- @see https://www.awsarchitectureblog.com/2015/03/backoff.html
76
+ rbs_type: '(:none | :equal | :full | ^(Integer) -> Integer)',
77
+ docstring: <<~DOCS)
78
+ A delay randomiser function used by the default backoff function.
79
+ Some predefined functions can be referenced by name - :none, :equal, :full,
80
+ otherwise a Proc that takes and returns a number. This option is only used
81
+ in the `legacy` retry mode.
82
+
83
+ @see https://www.awsarchitectureblog.com/2015/03/backoff.html
83
84
  DOCS
84
85
 
85
86
  option(
86
87
  :retry_backoff,
87
88
  default: DEFAULT_BACKOFF,
88
89
  doc_type: Proc,
89
- docstring: <<-DOCS)
90
- A proc or lambda used for backoff. Defaults to 2**retries * retry_base_delay.
91
- This option is only used in the `legacy` retry mode.
90
+ docstring: <<~DOCS)
91
+ A proc or lambda used for backoff. Defaults to 2**retries * retry_base_delay.
92
+ This option is only used in the `legacy` retry mode.
92
93
  DOCS
93
94
 
94
95
  # END LEGACY OPTIONS
95
96
 
96
97
  option(
97
98
  :retry_mode,
98
- default: 'legacy',
99
+ default: 'legacy', # TODO: Change to 'standard' when new retries become default
99
100
  doc_type: String,
100
- docstring: <<-DOCS) do |cfg|
101
- Specifies which retry algorithm to use. Values are:
102
-
103
- * `legacy` - The pre-existing retry behavior. This is default value if
104
- no retry mode is provided.
101
+ rbs_type: '("legacy" | "standard" | "adaptive")',
102
+ docstring: <<~DOCS) do |cfg|
103
+ Specifies which retry algorithm to use. Values are:
105
104
 
106
- * `standard` - A standardized set of retry rules across the AWS SDKs.
107
- This includes support for retry quotas, which limit the number of
108
- unsuccessful retries a client can make.
105
+ * `legacy` - The pre-existing retry behavior. This is the default
106
+ value if no retry mode is provided.
109
107
 
110
- * `adaptive` - An experimental retry mode that includes all the
111
- functionality of `standard` mode along with automatic client side
112
- throttling. This is a provisional mode that may change behavior
113
- in the future.
108
+ * `standard` - A standardized set of retry rules across the AWS SDKs.
109
+ This includes support for retry quotas, which limit the number of
110
+ unsuccessful retries a client can make.
114
111
 
112
+ * `adaptive` - A retry mode that includes all the functionality of
113
+ `standard` mode along with automatic client side throttling.
115
114
  DOCS
116
115
  resolve_retry_mode(cfg)
117
116
  end
@@ -120,11 +119,11 @@ Specifies which retry algorithm to use. Values are:
120
119
  :max_attempts,
121
120
  default: 3,
122
121
  doc_type: Integer,
123
- docstring: <<-DOCS) do |cfg|
124
- An integer representing the maximum number attempts that will be made for
125
- a single request, including the initial attempt. For example,
126
- setting this value to 5 will result in a request being retried up to
127
- 4 times. Used in `standard` and `adaptive` retry modes.
122
+ docstring: <<~DOCS) do |cfg|
123
+ An integer representing the maximum number attempts that will be made for
124
+ a single request, including the initial attempt. For example,
125
+ setting this value to 5 will result in a request being retried up to
126
+ 4 times. Used in `standard` and `adaptive` retry modes.
128
127
  DOCS
129
128
  resolve_max_attempts(cfg)
130
129
  end
@@ -133,11 +132,11 @@ setting this value to 5 will result in a request being retried up to
133
132
  :adaptive_retry_wait_to_fill,
134
133
  default: true,
135
134
  doc_type: 'Boolean',
136
- docstring: <<-DOCS) do |cfg|
137
- Used only in `adaptive` retry mode. When true, the request will sleep
138
- until there is sufficent client side capacity to retry the request.
139
- When false, the request will raise a `RetryCapacityNotAvailableError` and will
140
- not retry instead of sleeping.
135
+ docstring: <<~DOCS) do |cfg|
136
+ Used only in `adaptive` retry mode. When true, the request will sleep
137
+ until there is sufficent client side capacity to retry the request.
138
+ When false, the request will raise a `RetryCapacityNotAvailableError` and will
139
+ not retry instead of sleeping.
141
140
  DOCS
142
141
  resolve_adaptive_retry_wait_to_fill(cfg)
143
142
  end
@@ -146,10 +145,10 @@ not retry instead of sleeping.
146
145
  :correct_clock_skew,
147
146
  default: true,
148
147
  doc_type: 'Boolean',
149
- docstring: <<-DOCS) do |cfg|
150
- Used only in `standard` and adaptive retry modes. Specifies whether to apply
151
- a clock skew correction and retry requests with skewed client clocks.
152
- DOCS
148
+ docstring: <<~DOCS) do |cfg|
149
+ Used only in `standard` and `adaptive` retry modes. Specifies whether to apply
150
+ a clock skew correction and retry requests with skewed client clocks.
151
+ DOCS
153
152
  resolve_correct_clock_skew(cfg)
154
153
  end
155
154
 
@@ -162,78 +161,113 @@ a clock skew correction and retry requests with skewed client clocks.
162
161
  # @api private undocumented
163
162
  option(:clock_skew) { Retries::ClockSkew.new }
164
163
 
165
- def self.resolve_retry_mode(cfg)
166
- default_mode_value =
167
- if cfg.respond_to?(:defaults_mode_config_resolver)
168
- cfg.defaults_mode_config_resolver.resolve(:retry_mode)
169
- end
164
+ DYNAMODB_SERVICES = Set['DynamoDB', 'DynamoDB Streams'].freeze
165
+
166
+ class << self
167
+ # TODO: Remove this gate and hardcode new retry behavior once
168
+ # AWS_NEW_RETRIES_2026 is enabled by default, which includes:
169
+ # - Default retry_mode to 'standard'
170
+ # - Default max_attempts to 4 for DynamoDB
171
+ # - Remove the old retries branch in Handler#call
172
+ # - Remove the old retries branch in #exponential_backoff
173
+ # - Remove LEGACY_RETRY_COST and TIMEOUT_RETRY_COST from RetryQuota
174
+ def new_retries?
175
+ ENV.fetch('AWS_NEW_RETRIES_2026', 'false').downcase == 'true'
176
+ end
177
+
178
+ def resolve_retry_mode(cfg)
179
+ default_mode_value =
180
+ if cfg.respond_to?(:defaults_mode_config_resolver)
181
+ cfg.defaults_mode_config_resolver.resolve(:retry_mode)
182
+ end
170
183
 
171
184
  value = ENV['AWS_RETRY_MODE'] ||
172
185
  Aws.shared_config.retry_mode(profile: cfg.profile) ||
173
186
  default_mode_value ||
174
- 'legacy'
175
- # Raise if provided value is not one of the retry modes
176
- if value != 'legacy' && value != 'standard' && value != 'adaptive'
177
- raise ArgumentError,
178
- 'Must provide either `legacy`, `standard`, or `adaptive` for '\
179
- 'retry_mode profile option or for ENV[\'AWS_RETRY_MODE\']'
187
+ (new_retries? ? 'standard' : 'legacy') # TODO: default to 'standard' when new retries become default
188
+ # Raise if provided value is not one of the retry modes
189
+ if value != 'legacy' && value != 'standard' && value != 'adaptive'
190
+ raise ArgumentError,
191
+ 'Must provide either `legacy`, `standard`, or `adaptive` for '\
192
+ 'retry_mode profile option or for ENV[\'AWS_RETRY_MODE\']'
193
+ end
194
+ value
180
195
  end
181
- value
182
- end
183
196
 
184
- def self.resolve_max_attempts(cfg)
185
- value = (ENV['AWS_MAX_ATTEMPTS']) ||
186
- Aws.shared_config.max_attempts(profile: cfg.profile) ||
187
- '3'
188
- value = value.to_i
189
- # Raise if provided value is not a positive integer
190
- if value <= 0
191
- raise ArgumentError,
192
- 'Must provide a positive integer for max_attempts profile '\
193
- 'option or for ENV[\'AWS_MAX_ATTEMPTS\']'
197
+ def resolve_max_attempts(cfg)
198
+ value = (ENV['AWS_MAX_ATTEMPTS']) ||
199
+ Aws.shared_config.max_attempts(profile: cfg.profile)
200
+ if value
201
+ value = value.to_i
202
+ # Raise if provided value is not a positive integer
203
+ if value <= 0
204
+ raise ArgumentError,
205
+ 'Must provide a positive integer for max_attempts profile '\
206
+ 'option or for ENV[\'AWS_MAX_ATTEMPTS\']'
207
+ end
208
+ return value
209
+ end
210
+
211
+ default_max_attempts(cfg)
194
212
  end
195
- value
196
- end
197
213
 
198
- def self.resolve_adaptive_retry_wait_to_fill(cfg)
199
- value = ENV['AWS_ADAPTIVE_RETRY_WAIT_TO_FILL'] ||
200
- Aws.shared_config.adaptive_retry_wait_to_fill(profile: cfg.profile) ||
201
- 'true'
202
- # Raise if provided value is not true or false
203
- if value != 'true' && value != 'false'
204
- raise ArgumentError,
205
- 'Must provide either `true` or `false` for '\
206
- 'adaptive_retry_wait_to_fill profile option or for '\
207
- 'ENV[\'AWS_ADAPTIVE_RETRY_WAIT_TO_FILL\']'
214
+ def default_max_attempts(cfg)
215
+ # TODO: Remove gate and keep only the new retries branch
216
+ return 3 unless new_retries?
217
+
218
+ service_id = cfg.api.metadata['serviceId'] if cfg.respond_to?(:api)
219
+ DYNAMODB_SERVICES.include?(service_id) ? 4 : 3
208
220
  end
209
- value == 'true'
210
- end
211
221
 
212
- def self.resolve_correct_clock_skew(cfg)
213
- value = ENV['AWS_CORRECT_CLOCK_SKEW'] ||
214
- Aws.shared_config.correct_clock_skew(profile: cfg.profile) ||
215
- 'true'
216
- # Raise if provided value is not true or false
217
- if value != 'true' && value != 'false'
218
- raise ArgumentError,
219
- 'Must provide either `true` or `false` for '\
220
- 'correct_clock_skew profile option or for '\
221
- 'ENV[\'AWS_CORRECT_CLOCK_SKEW\']'
222
+ def resolve_adaptive_retry_wait_to_fill(cfg)
223
+ value = ENV['AWS_ADAPTIVE_RETRY_WAIT_TO_FILL'] ||
224
+ Aws.shared_config.adaptive_retry_wait_to_fill(profile: cfg.profile) ||
225
+ 'true'
226
+ # Raise if provided value is not true or false
227
+ if value != 'true' && value != 'false'
228
+ raise ArgumentError,
229
+ 'Must provide either `true` or `false` for '\
230
+ 'adaptive_retry_wait_to_fill profile option or for '\
231
+ 'ENV[\'AWS_ADAPTIVE_RETRY_WAIT_TO_FILL\']'
232
+ end
233
+ value == 'true'
234
+ end
235
+
236
+ def resolve_correct_clock_skew(cfg)
237
+ value = ENV['AWS_CORRECT_CLOCK_SKEW'] ||
238
+ Aws.shared_config.correct_clock_skew(profile: cfg.profile) ||
239
+ 'true'
240
+ # Raise if provided value is not true or false
241
+ if value != 'true' && value != 'false'
242
+ raise ArgumentError,
243
+ 'Must provide either `true` or `false` for '\
244
+ 'correct_clock_skew profile option or for '\
245
+ 'ENV[\'AWS_CORRECT_CLOCK_SKEW\']'
246
+ end
247
+ value == 'true'
222
248
  end
223
- value == 'true'
224
249
  end
225
250
 
226
251
  class Handler < Seahorse::Client::Handler
227
252
  # Max backoff (in seconds)
228
253
  MAX_BACKOFF = 20
229
254
 
255
+ # TODO: remove once longPoll trait is added to models
256
+ # Hard-coded combination of services and operations as having the
257
+ # longPoll trait. To be removed when trait is enabled.
258
+ LONG_POLLING_OPERATIONS = {
259
+ 'SQS' => Set[:receive_message],
260
+ 'SFN' => Set[:get_activity_task],
261
+ 'SWF' => Set[:poll_for_activity_task, :poll_for_decision_task]
262
+ }.freeze
263
+
230
264
  def call(context)
231
265
  context.metadata[:retries] ||= {}
232
266
  config = context.config
233
267
 
234
268
  get_send_token(config)
235
269
  add_retry_headers(context)
236
- response = @handler.call(context)
270
+ response = with_metric(config.retry_mode) { @handler.call(context) }
237
271
  error_inspector = Retries::ErrorInspector.new(
238
272
  response.error, response.context.http_response.status_code
239
273
  )
@@ -259,17 +293,38 @@ a clock skew correction and retry requests with skewed client clocks.
259
293
 
260
294
  return response if context.retries >= config.max_attempts - 1
261
295
 
262
- context.metadata[:retries][:capacity_amount] =
263
- config.retry_quota.checkout_capacity(error_inspector)
264
- return response unless context.metadata[:retries][:capacity_amount] > 0
296
+ capacity_amount = config.retry_quota.checkout_capacity(error_inspector)
297
+ context.metadata[:retries][:capacity_amount] = capacity_amount
298
+
299
+ # TODO: Remove gate and keep only the new retries branch
300
+ if new_retries?
301
+ return response if capacity_amount <= 0 && !long_polling_operation?(context)
302
+
303
+ service_id = context.config.api.metadata['serviceId']
304
+ delay = backoff(context, error_inspector, service_id)
305
+ Kernel.sleep(delay)
306
+
307
+ return response if capacity_amount <= 0
308
+ else
309
+ return response unless capacity_amount > 0
310
+
311
+ delay = exponential_backoff(context.retries)
312
+ Kernel.sleep(delay)
313
+ end
265
314
 
266
- delay = exponential_backoff(context.retries)
267
- Kernel.sleep(delay)
268
315
  retry_request(context, error_inspector)
269
316
  end
270
317
 
271
318
  private
272
319
 
320
+ def new_retries?
321
+ RetryErrors.new_retries?
322
+ end
323
+
324
+ def with_metric(retry_mode, &block)
325
+ Aws::Plugins::UserAgent.metric("RETRY_MODE_#{retry_mode.upcase}", &block)
326
+ end
327
+
273
328
  def get_send_token(config)
274
329
  # either fail fast or block until a token becomes available
275
330
  # must be configurable
@@ -306,9 +361,51 @@ a clock skew correction and retry requests with skewed client clocks.
306
361
  context.http_response.body.respond_to?(:truncate)
307
362
  end
308
363
 
309
- def exponential_backoff(retries)
310
- # for a transient error, use backoff
311
- [Kernel.rand * 2**retries, MAX_BACKOFF].min
364
+ def long_polling_operation?(context)
365
+ return true if context.operation['longPoll']
366
+
367
+ # Hard-coded failback until the trait is enabled
368
+ service_id = context.config.api.metadata['serviceId']
369
+ LONG_POLLING_OPERATIONS[service_id]&.include?(context.operation_name)
370
+ end
371
+
372
+ def backoff(context, error_inspector, service_id)
373
+ exp_backoff = exponential_backoff(context.retries, error_inspector, service_id)
374
+ retry_after = parse_retry_after(context)
375
+ return exp_backoff unless retry_after
376
+
377
+ backoff_duration = [retry_after, exp_backoff].max
378
+ [backoff_duration, exp_backoff + 5].min
379
+ end
380
+
381
+ # TODO: Remove gate, remove default nil params, keep only new retries branch
382
+ def exponential_backoff(retries, error_inspector = nil, service_id = nil)
383
+ if new_retries?
384
+ backoff_scalar = if error_inspector.throttling_error?
385
+ 1
386
+ elsif DYNAMODB_SERVICES.include?(service_id)
387
+ 0.025
388
+ else
389
+ 0.05
390
+ end
391
+ Kernel.rand * [backoff_scalar * 2**retries, MAX_BACKOFF].min
392
+ else
393
+ [Kernel.rand * 2**retries, MAX_BACKOFF].min
394
+ end
395
+ end
396
+
397
+ def parse_retry_after(context)
398
+ retry_after = context.http_response.headers['x-amz-retry-after']
399
+ return unless retry_after
400
+
401
+ unless retry_after.match?(/\A\d+\z/)
402
+ context.config.logger&.debug(
403
+ "Failed to parse x-amz-retry-after header value: #{retry_after.inspect}"
404
+ )
405
+ return
406
+ end
407
+
408
+ retry_after.to_i / 1000.0
312
409
  end
313
410
 
314
411
  def retry_request(context, error)
@@ -326,7 +423,7 @@ a clock skew correction and retry requests with skewed client clocks.
326
423
 
327
424
  def add_retry_headers(context)
328
425
  request_pairs = {
329
- 'attempt' => context.retries,
426
+ 'attempt' => context.retries + 1,
330
427
  'max' => context.config.max_attempts
331
428
  }
332
429
  if (ttl = compute_request_ttl(context))
@@ -357,7 +454,7 @@ a clock skew correction and retry requests with skewed client clocks.
357
454
  class LegacyHandler < Seahorse::Client::Handler
358
455
 
359
456
  def call(context)
360
- response = @handler.call(context)
457
+ response = with_metric { @handler.call(context) }
361
458
  if response.error
362
459
  error_inspector = Retries::ErrorInspector.new(
363
460
  response.error, response.context.http_response.status_code
@@ -376,6 +473,10 @@ a clock skew correction and retry requests with skewed client clocks.
376
473
 
377
474
  private
378
475
 
476
+ def with_metric(&block)
477
+ Aws::Plugins::UserAgent.metric('RETRY_MODE_LEGACY', &block)
478
+ end
479
+
379
480
  def retry_if_possible(response, error_inspector)
380
481
  context = response.context
381
482
  if should_retry?(context, error_inspector)
@@ -13,10 +13,6 @@ module Aws
13
13
  option(:sigv4_region)
14
14
  option(:unsigned_operations, default: [])
15
15
 
16
- supported_auth_types = %w[sigv4 bearer none]
17
- supported_auth_types += ['sigv4a'] if Aws::Sigv4::Signer.use_crt?
18
- SUPPORTED_AUTH_TYPES = supported_auth_types.freeze
19
-
20
16
  def add_handlers(handlers, cfg)
21
17
  operations = cfg.api.operation_names - cfg.unsigned_operations
22
18
  handlers.add(Handler, step: :sign, operations: operations)
@@ -24,12 +20,16 @@ module Aws
24
20
 
25
21
  # @api private
26
22
  # Return a signer with the `sign(context)` method
27
- def self.signer_for(auth_scheme, config, region_override = nil)
23
+ def self.signer_for(auth_scheme, config, sigv4_region_override = nil, sigv4_credentials_override = nil)
28
24
  case auth_scheme['name']
29
- when 'sigv4', 'sigv4a'
30
- SignatureV4.new(auth_scheme, config, region_override)
25
+ when 'sigv4', 'sigv4a', 'sigv4-s3express'
26
+ sigv4_overrides = {
27
+ region: sigv4_region_override,
28
+ credentials: sigv4_credentials_override
29
+ }
30
+ SignatureV4.new(auth_scheme, config, sigv4_overrides)
31
31
  when 'bearer'
32
- Bearer.new
32
+ Bearer.new(config)
33
33
  else
34
34
  NullSigner.new
35
35
  end
@@ -42,15 +42,27 @@ module Aws
42
42
  signer = Sign.signer_for(
43
43
  context[:auth_scheme],
44
44
  context.config,
45
- context[:sigv4_region]
45
+ context[:sigv4_region],
46
+ context[:sigv4_credentials]
46
47
  )
47
48
  signer.sign(context)
48
49
  end
49
- @handler.call(context)
50
+ with_metrics(signer) { @handler.call(context) }
50
51
  end
51
52
 
52
53
  private
53
54
 
55
+ def with_metrics(signer, &block)
56
+ case signer
57
+ when SignatureV4
58
+ Aws::Plugins::UserAgent.metric(*signer.credentials.metrics, &block)
59
+ when Bearer
60
+ Aws::Plugins::UserAgent.metric(*signer.token_provider.metrics, &block)
61
+ else
62
+ block.call
63
+ end
64
+ end
65
+
54
66
  def v2_signing?(config)
55
67
  # 's3' is legacy signing, 'v4' is default
56
68
  config.respond_to?(:signature_version) &&
@@ -60,21 +72,19 @@ module Aws
60
72
 
61
73
  # @api private
62
74
  class Bearer
63
- def initialize
75
+ def initialize(config)
76
+ @token_provider = config.token_provider
64
77
  end
65
78
 
79
+ attr_reader :token_provider
80
+
66
81
  def sign(context)
67
82
  if context.http_request.endpoint.scheme != 'https'
68
- raise ArgumentError,
69
- 'Unable to use bearer authorization on non https endpoint.'
83
+ raise ArgumentError, 'Unable to use bearer authorization on non https endpoint.'
70
84
  end
85
+ raise Errors::MissingBearerTokenError unless @token_provider && @token_provider.set?
71
86
 
72
- token_provider = context.config.token_provider
73
-
74
- raise Errors::MissingBearerTokenError unless token_provider&.set?
75
-
76
- context.http_request.headers['Authorization'] =
77
- "Bearer #{token_provider.token.token}"
87
+ context.http_request.headers['Authorization'] = "Bearer #{@token_provider.token.token}"
78
88
  end
79
89
 
80
90
  def presign_url(*args)
@@ -88,33 +98,33 @@ module Aws
88
98
 
89
99
  # @api private
90
100
  class SignatureV4
91
- def initialize(auth_scheme, config, region_override = nil)
101
+ def initialize(auth_scheme, config, sigv4_overrides = {})
92
102
  scheme_name = auth_scheme['name']
93
-
94
- unless %w[sigv4 sigv4a].include?(scheme_name)
95
- raise ArgumentError,
96
- "Expected sigv4 or sigv4a auth scheme, got #{scheme_name}"
103
+ unless %w[sigv4 sigv4a sigv4-s3express].include?(scheme_name)
104
+ raise ArgumentError, "Expected sigv4, sigv4a, or sigv4-s3express auth scheme, got #{scheme_name}"
97
105
  end
98
-
99
106
  region = if scheme_name == 'sigv4a'
100
- auth_scheme['signingRegionSet'].first
107
+ auth_scheme['signingRegionSet'].join(',')
101
108
  else
102
109
  auth_scheme['signingRegion']
103
110
  end
104
111
  begin
105
- @signer = Aws::Sigv4::Signer.new(
112
+ @signer = config.sigv4_signer || Aws::Sigv4::Signer.new(
106
113
  service: config.sigv4_name || auth_scheme['signingName'],
107
- region: region_override || config.sigv4_region || region,
108
- credentials_provider: config.credentials,
114
+ region: sigv4_overrides[:region] || config.sigv4_region || region,
115
+ credentials_provider: sigv4_overrides[:credentials] || config.credentials,
109
116
  signing_algorithm: scheme_name.to_sym,
110
- uri_escape_path: !!!auth_scheme['disableDoubleEncoding'],
111
- unsigned_headers: %w[content-length user-agent x-amzn-trace-id]
117
+ uri_escape_path: !auth_scheme['disableDoubleEncoding'],
118
+ normalize_path: !auth_scheme['disableNormalizePath'],
119
+ unsigned_headers: %w[content-length user-agent x-amzn-trace-id expect transfer-encoding connection]
112
120
  )
113
121
  rescue Aws::Sigv4::Errors::MissingCredentialsError
114
122
  raise Aws::Errors::MissingCredentialsError
115
123
  end
116
124
  end
117
125
 
126
+ attr_reader :signer
127
+
118
128
  def sign(context)
119
129
  req = context.http_request
120
130
 
@@ -150,15 +160,27 @@ module Aws
150
160
  @signer.sign_event(*args)
151
161
  end
152
162
 
163
+ def credentials
164
+ @signer.credentials_provider
165
+ end
166
+
153
167
  private
154
168
 
155
169
  def apply_authtype(context, req)
156
- if context.operation['authtype'].eql?('v4-unsigned-body') &&
157
- req.endpoint.scheme.eql?('https')
170
+ # only used for event streaming at input
171
+ if context[:input_event_emitter]
172
+ req.headers['X-Amz-Content-Sha256'] = 'STREAMING-AWS4-HMAC-SHA256-EVENTS'
173
+ elsif unsigned_payload?(context, req)
158
174
  req.headers['X-Amz-Content-Sha256'] ||= 'UNSIGNED-PAYLOAD'
159
175
  end
160
176
  end
161
177
 
178
+ def unsigned_payload?(context, req)
179
+ (context.operation['unsignedPayload'] ||
180
+ context.operation['authtype'] == 'v4-unsigned-body') &&
181
+ req.endpoint.scheme == 'https'
182
+ end
183
+
162
184
  def reset_signature(req)
163
185
  # in case this request is being re-signed
164
186
  req.headers.delete('Authorization')
@@ -3,7 +3,8 @@
3
3
  module Aws
4
4
  module Plugins
5
5
  # @api private
6
- # Necessary to keep after Endpoints 2.0
6
+ # Deprecated - does not look at new traits like `auth` and `unsignedPayload`
7
+ # Necessary to exist after endpoints 2.0 for old service clients + new core
7
8
  class SignatureV2 < Seahorse::Client::Plugin
8
9
 
9
10
  option(:v2_signer) do |cfg|
@@ -5,7 +5,8 @@ require 'aws-sigv4'
5
5
  module Aws
6
6
  module Plugins
7
7
  # @api private
8
- # Necessary to exist after endpoints 2.0
8
+ # Deprecated - does not look at new traits like `auth` and `unsignedPayload`
9
+ # Necessary to exist after endpoints 2.0 for old service clients + new core
9
10
  class SignatureV4 < Seahorse::Client::Plugin
10
11
 
11
12
  V4_AUTH = %w[v4 v4-unsigned-payload v4-unsigned-body]