aws-sdk-core 3.165.0 → 3.174.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +105 -0
  3. data/VERSION +1 -1
  4. data/lib/aws-sdk-core/credential_provider_chain.rb +8 -5
  5. data/lib/aws-sdk-core/ecs_credentials.rb +111 -53
  6. data/lib/aws-sdk-core/endpoints/condition.rb +5 -0
  7. data/lib/aws-sdk-core/endpoints/endpoint_rule.rb +5 -1
  8. data/lib/aws-sdk-core/endpoints/error_rule.rb +5 -0
  9. data/lib/aws-sdk-core/endpoints/function.rb +5 -0
  10. data/lib/aws-sdk-core/endpoints/reference.rb +5 -0
  11. data/lib/aws-sdk-core/endpoints/rule.rb +5 -0
  12. data/lib/aws-sdk-core/endpoints/rule_set.rb +5 -0
  13. data/lib/aws-sdk-core/endpoints/rules_provider.rb +5 -0
  14. data/lib/aws-sdk-core/endpoints/templater.rb +6 -0
  15. data/lib/aws-sdk-core/endpoints/tree_rule.rb +5 -0
  16. data/lib/aws-sdk-core/endpoints/url.rb +1 -0
  17. data/lib/aws-sdk-core/json/error_handler.rb +15 -5
  18. data/lib/aws-sdk-core/log/formatter.rb +6 -0
  19. data/lib/aws-sdk-core/pageable_response.rb +3 -1
  20. data/lib/aws-sdk-core/plugins/checksum_algorithm.rb +1 -1
  21. data/lib/aws-sdk-core/plugins/retries/error_inspector.rb +2 -1
  22. data/lib/aws-sdk-core/plugins/sign.rb +17 -7
  23. data/lib/aws-sdk-core/plugins/user_agent.rb +117 -14
  24. data/lib/aws-sdk-core/shared_config.rb +38 -9
  25. data/lib/aws-sdk-core/sso_credentials.rb +79 -44
  26. data/lib/aws-sdk-core/sso_token_provider.rb +3 -2
  27. data/lib/aws-sdk-core/waiters/poller.rb +3 -1
  28. data/lib/aws-sdk-core/xml/parser/engines/oga.rb +2 -0
  29. data/lib/aws-sdk-core.rb +1 -0
  30. data/lib/aws-sdk-sso/client.rb +6 -1
  31. data/lib/aws-sdk-sso/endpoint_provider.rb +35 -96
  32. data/lib/aws-sdk-sso/types.rb +0 -35
  33. data/lib/aws-sdk-sso.rb +1 -1
  34. data/lib/aws-sdk-ssooidc/client.rb +6 -1
  35. data/lib/aws-sdk-ssooidc/endpoint_provider.rb +35 -95
  36. data/lib/aws-sdk-ssooidc/types.rb +0 -32
  37. data/lib/aws-sdk-ssooidc.rb +1 -1
  38. data/lib/aws-sdk-sts/client.rb +244 -241
  39. data/lib/aws-sdk-sts/endpoint_provider.rb +96 -213
  40. data/lib/aws-sdk-sts/types.rb +87 -195
  41. data/lib/aws-sdk-sts.rb +1 -1
  42. data/lib/seahorse/client/h2/connection.rb +12 -11
  43. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df67380b30b1758bb4301b6c2c267866a5e62b068111975c5331ac20fe6290a4
4
- data.tar.gz: b91374a34d93f7d328f8820a2ba89c6384fbf4dfe6254be974fe4d0b492dbbdf
3
+ metadata.gz: d4ecec9eaf3fee0d30bdd88558775c3553537df9dfd3fe4f62b694cba78b7991
4
+ data.tar.gz: f99bff124648f74105f216af8de264e71151357a4ec645531d5c59dcfc696ef9
5
5
  SHA512:
6
- metadata.gz: '0927312f09c93e40c158b18ac109c8bdee223aef6972868203d63cbd2120522367bc9448dc61f27cf445757ba9f5c00760122be8c469997b5b48fff19e2d9eeb'
7
- data.tar.gz: 1a65436045eb469c4b1a18b3d7caa36be6659affb6e1dfd24dacf15587025585336bf0f8297f258f999471b2d1ed2f933e599230404fbd12ee6bc69bdc475ad7
6
+ metadata.gz: 2753ea337d9adde1dab3fbe9d72fbb3f31e9a8061e1a7be017f0eb48a1b56958edd03f8b84c2d634ff10254e4a7a565b40163739497420d5171affd6c880600f
7
+ data.tar.gz: 767e58ebbbf1f3e95e835f86cffda3bc4ed9ba99f5fdc663fcb65c0996f15df918f30a6f27b8cf70b2c888a4dc315c9338c717508bc98f5e75b3f3568ff7a00b
data/CHANGELOG.md CHANGED
@@ -1,6 +1,111 @@
1
1
  Unreleased Changes
2
2
  ------------------
3
3
 
4
+ 3.174.0 (2023-05-31)
5
+ ------------------
6
+
7
+ * Feature - Updated Aws::STS::Client with the latest API changes.
8
+
9
+ * Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
10
+
11
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
12
+
13
+ * Feature - Improve User-Agent metrics tracking.
14
+
15
+ 3.173.1 (2023-05-24)
16
+ ------------------
17
+
18
+ * Issue - Updated `checksum_algorithm` plugin to use IO.copy_stream for JRuby.
19
+
20
+ 3.173.0 (2023-05-18)
21
+ ------------------
22
+
23
+ * Feature - Updated Aws::STS::Client with the latest API changes.
24
+
25
+ 3.172.0 (2023-05-08)
26
+ ------------------
27
+
28
+ * Feature - Updated Aws::STS::Client with the latest API changes.
29
+
30
+ * Feature - Add :region option to `Aws::Log::Formatter`.
31
+
32
+ 3.171.1 (2023-05-04)
33
+ ------------------
34
+
35
+ * Issue - Fix error code parsing in AWS query compatible JSON services.
36
+
37
+ 3.171.0 (2023-03-22)
38
+ ------------------
39
+
40
+ * Feature - Add support for `AWS_CONTAINER_CREDENTIALS_FULL_URI` and `AWS_CONTAINER_AUTHORIZATION_TOKEN` environment variables to `ECSCredentials`.
41
+
42
+ 3.170.1 (2023-03-17)
43
+ ------------------
44
+
45
+ * Issue - Reduce memory usage in H2::Connection when `http_wire_log` is not set.
46
+
47
+ 3.170.0 (2023-01-25)
48
+ ------------------
49
+
50
+ * Feature - Updated Aws::STS::Client with the latest API changes.
51
+
52
+ 3.169.0 (2023-01-18)
53
+ ------------------
54
+
55
+ * Feature - Updated Aws::STS::Client with the latest API changes.
56
+
57
+ * Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
58
+
59
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
60
+
61
+ * Issue - Replace runtime endpoint resolution approach with generated ruby code for STS, SSO, and SSOOIDC.
62
+
63
+ 3.168.4 (2022-12-08)
64
+ ------------------
65
+
66
+ * Issue - Fix Sign to not sign Sigv2 requests to S3.
67
+
68
+ 3.168.3 (2022-12-02)
69
+ ------------------
70
+
71
+ * Issue - Retry S3's `BadDigest` error
72
+
73
+ 3.168.2 (2022-11-29)
74
+ ------------------
75
+
76
+ * Issue - Allow region resolution in `AssumeRoleCredentials` from `CredentialProviderChain`.
77
+
78
+ 3.168.1 (2022-11-18)
79
+ ------------------
80
+
81
+ * Issue - Fix initialization of SSOTokenProvider when `AWS_PROFILE` is specified.
82
+
83
+ 3.168.0 (2022-11-17)
84
+ ------------------
85
+
86
+ * Feature - Updated Aws::STS::Client with the latest API changes.
87
+
88
+ 3.167.0 (2022-11-09)
89
+ ------------------
90
+
91
+ * Issue - Ensure the stream_thread is not killed before H2 connection status is updated (#2779).
92
+
93
+ * Feature - Add token refresh support to `SSOCredentialProvider`.
94
+
95
+ 3.166.0 (2022-10-26)
96
+ ------------------
97
+
98
+ * Feature - Updated Aws::STS::Client with the latest API changes.
99
+
100
+ * Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
101
+
102
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
103
+
104
+ 3.165.1 (2022-10-25)
105
+ ------------------
106
+
107
+ * Issue - Require the SignatureV4 plugin to fix compatability with older `aws-sdk-s3` versions (#2774).
108
+
4
109
  3.165.0 (2022-10-25)
5
110
  ------------------
6
111
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.165.0
1
+ 3.174.0
@@ -161,7 +161,8 @@ module Aws
161
161
 
162
162
  def instance_profile_credentials(options)
163
163
  profile_name = determine_profile_name(options)
164
- if ENV['AWS_CONTAINER_CREDENTIALS_RELATIVE_URI']
164
+ if ENV['AWS_CONTAINER_CREDENTIALS_RELATIVE_URI'] ||
165
+ ENV['AWS_CONTAINER_CREDENTIALS_FULL_URI']
165
166
  ECSCredentials.new(options)
166
167
  else
167
168
  InstanceProfileCredentials.new(options.merge(profile: profile_name))
@@ -169,12 +170,14 @@ module Aws
169
170
  end
170
171
 
171
172
  def assume_role_with_profile(options, profile_name)
172
- region = (options[:config] && options[:config].region)
173
- Aws.shared_config.assume_role_credentials_from_config(
173
+ assume_opts = {
174
174
  profile: profile_name,
175
- region: region,
176
175
  chain_config: @config
177
- )
176
+ }
177
+ if options[:config] && options[:config].region
178
+ assume_opts[:region] = options[:config].region
179
+ end
180
+ Aws.shared_config.assume_role_credentials_from_config(assume_opts)
178
181
  end
179
182
  end
180
183
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'time'
4
4
  require 'net/http'
5
+ require 'resolv'
5
6
 
6
7
  module Aws
7
8
  # An auto-refreshing credential provider that loads credentials from
@@ -10,7 +11,6 @@ module Aws
10
11
  # ecs_credentials = Aws::ECSCredentials.new(retries: 3)
11
12
  # ec2 = Aws::EC2::Client.new(credentials: ecs_credentials)
12
13
  class ECSCredentials
13
-
14
14
  include CredentialProvider
15
15
  include RefreshingCredentials
16
16
 
@@ -29,16 +29,22 @@ module Aws
29
29
  Errno::ENETUNREACH,
30
30
  SocketError,
31
31
  Timeout::Error,
32
- Non200Response,
33
- ]
32
+ Non200Response
33
+ ].freeze
34
34
 
35
35
  # @param [Hash] options
36
36
  # @option options [Integer] :retries (5) Number of times to retry
37
37
  # when retrieving credentials.
38
- # @option options [String] :ip_address ('169.254.170.2')
39
- # @option options [Integer] :port (80)
38
+ # @option options [String] :ip_address ('169.254.170.2') This value is
39
+ # ignored if `endpoint` is set and `credential_path` is not set.
40
+ # @option options [Integer] :port (80) This value is ignored if `endpoint`
41
+ # is set and `credential_path` is not set.
40
42
  # @option options [String] :credential_path By default, the value of the
41
43
  # AWS_CONTAINER_CREDENTIALS_RELATIVE_URI environment variable.
44
+ # @option options [String] :endpoint The ECS credential endpoint.
45
+ # By default, this is the value of the AWS_CONTAINER_CREDENTIALS_FULL_URI
46
+ # environment variable. This value is ignored if `credential_path` or
47
+ # ENV['AWS_CONTAINER_CREDENTIALS_RELATIVE_URI'] is set.
42
48
  # @option options [Float] :http_open_timeout (5)
43
49
  # @option options [Float] :http_read_timeout (5)
44
50
  # @option options [Numeric, Proc] :delay By default, failures are retried
@@ -52,17 +58,15 @@ module Aws
52
58
  # credentials are refreshed. `before_refresh` is called
53
59
  # with an instance of this object when
54
60
  # AWS credentials are required and need to be refreshed.
55
- def initialize options = {}
61
+ def initialize(options = {})
62
+ credential_path = options[:credential_path] ||
63
+ ENV['AWS_CONTAINER_CREDENTIALS_RELATIVE_URI']
64
+ endpoint = options[:endpoint] ||
65
+ ENV['AWS_CONTAINER_CREDENTIALS_FULL_URI']
66
+ initialize_uri(options, credential_path, endpoint)
67
+ @authorization_token = ENV['AWS_CONTAINER_AUTHORIZATION_TOKEN']
68
+
56
69
  @retries = options[:retries] || 5
57
- @ip_address = options[:ip_address] || '169.254.170.2'
58
- @port = options[:port] || 80
59
- @credential_path = options[:credential_path]
60
- @credential_path ||= ENV['AWS_CONTAINER_CREDENTIALS_RELATIVE_URI']
61
- unless @credential_path
62
- raise ArgumentError.new(
63
- "Cannot instantiate an ECS Credential Provider without a credential path."
64
- )
65
- end
66
70
  @http_open_timeout = options[:http_open_timeout] || 5
67
71
  @http_read_timeout = options[:http_read_timeout] || 5
68
72
  @http_debug_output = options[:http_debug_output]
@@ -77,11 +81,69 @@ module Aws
77
81
 
78
82
  private
79
83
 
84
+ def initialize_uri(options, credential_path, endpoint)
85
+ if credential_path
86
+ initialize_relative_uri(options, credential_path)
87
+ # Use FULL_URI/endpoint only if RELATIVE_URI/path is not set
88
+ elsif endpoint
89
+ initialize_full_uri(endpoint)
90
+ else
91
+ raise ArgumentError,
92
+ 'Cannot instantiate an ECS Credential Provider '\
93
+ 'without a credential path or endpoint.'
94
+ end
95
+ end
96
+
97
+ def initialize_relative_uri(options, path)
98
+ @host = options[:ip_address] || '169.254.170.2'
99
+ @port = options[:port] || 80
100
+ @scheme = 'http'
101
+ @credential_path = path
102
+ end
103
+
104
+ def initialize_full_uri(endpoint)
105
+ uri = URI.parse(endpoint)
106
+ validate_full_uri!(uri)
107
+ @host = uri.host
108
+ @port = uri.port
109
+ @scheme = uri.scheme
110
+ @credential_path = uri.path
111
+ end
112
+
113
+ # Validate that the full URI is using a loopback address if scheme is http.
114
+ def validate_full_uri!(full_uri)
115
+ return unless full_uri.scheme == 'http'
116
+
117
+ begin
118
+ return if ip_loopback?(IPAddr.new(full_uri.host))
119
+ rescue IPAddr::InvalidAddressError
120
+ addresses = Resolv.getaddresses(full_uri.host)
121
+ return if addresses.all? { |addr| ip_loopback?(IPAddr.new(addr)) }
122
+ end
123
+
124
+ raise ArgumentError,
125
+ 'AWS_CONTAINER_CREDENTIALS_FULL_URI must use a loopback '\
126
+ 'address when using the http scheme.'
127
+ end
128
+
129
+ # loopback? method is available in Ruby 2.5+
130
+ # Replicate the logic here.
131
+ def ip_loopback?(ip_address)
132
+ case ip_address.family
133
+ when Socket::AF_INET
134
+ ip_address & 0xff000000 == 0x7f000000
135
+ when Socket::AF_INET6
136
+ ip_address == 1
137
+ else
138
+ false
139
+ end
140
+ end
141
+
80
142
  def backoff(backoff)
81
143
  case backoff
82
144
  when Proc then backoff
83
- when Numeric then lambda { |_| sleep(backoff) }
84
- else lambda { |num_failures| Kernel.sleep(1.2 ** num_failures) }
145
+ when Numeric then ->(_) { sleep(backoff) }
146
+ else ->(num_failures) { Kernel.sleep(1.2**num_failures) }
85
147
  end
86
148
  end
87
149
 
@@ -89,68 +151,64 @@ module Aws
89
151
  # Retry loading credentials up to 3 times is the instance metadata
90
152
  # service is responding but is returning invalid JSON documents
91
153
  # in response to the GET profile credentials call.
92
- begin
93
- retry_errors([Aws::Json::ParseError, StandardError], max_retries: 3) do
94
- c = Aws::Json.load(get_credentials.to_s)
95
- @credentials = Credentials.new(
96
- c['AccessKeyId'],
97
- c['SecretAccessKey'],
98
- c['Token']
99
- )
100
- @expiration = c['Expiration'] ? Time.iso8601(c['Expiration']) : nil
101
- end
102
- rescue Aws::Json::ParseError
103
- raise Aws::Errors::MetadataParserError.new
154
+
155
+ retry_errors([Aws::Json::ParseError, StandardError], max_retries: 3) do
156
+ c = Aws::Json.load(get_credentials.to_s)
157
+ @credentials = Credentials.new(
158
+ c['AccessKeyId'],
159
+ c['SecretAccessKey'],
160
+ c['Token']
161
+ )
162
+ @expiration = c['Expiration'] ? Time.iso8601(c['Expiration']) : nil
104
163
  end
164
+ rescue Aws::Json::ParseError
165
+ raise Aws::Errors::MetadataParserError
105
166
  end
106
167
 
107
168
  def get_credentials
108
169
  # Retry loading credentials a configurable number of times if
109
170
  # the instance metadata service is not responding.
110
- begin
111
- retry_errors(NETWORK_ERRORS, max_retries: @retries) do
112
- open_connection do |conn|
113
- http_get(conn, @credential_path)
114
- end
171
+
172
+ retry_errors(NETWORK_ERRORS, max_retries: @retries) do
173
+ open_connection do |conn|
174
+ http_get(conn, @credential_path)
115
175
  end
116
- rescue
117
- '{}'
118
176
  end
177
+ rescue StandardError
178
+ '{}'
119
179
  end
120
180
 
121
181
  def open_connection
122
- http = Net::HTTP.new(@ip_address, @port, nil)
182
+ http = Net::HTTP.new(@host, @port, nil)
123
183
  http.open_timeout = @http_open_timeout
124
184
  http.read_timeout = @http_read_timeout
125
185
  http.set_debug_output(@http_debug_output) if @http_debug_output
186
+ http.use_ssl = @scheme == 'https'
126
187
  http.start
127
188
  yield(http).tap { http.finish }
128
189
  end
129
190
 
130
191
  def http_get(connection, path)
131
- response = connection.request(Net::HTTP::Get.new(path))
132
- if response.code.to_i == 200
133
- response.body
134
- else
135
- raise Non200Response
136
- end
192
+ request = Net::HTTP::Get.new(path)
193
+ request['Authorization'] = @authorization_token if @authorization_token
194
+ response = connection.request(request)
195
+ raise Non200Response unless response.code.to_i == 200
196
+
197
+ response.body
137
198
  end
138
199
 
139
- def retry_errors(error_classes, options = {}, &block)
200
+ def retry_errors(error_classes, options = {})
140
201
  max_retries = options[:max_retries]
141
202
  retries = 0
142
203
  begin
143
204
  yield
144
- rescue *error_classes => _error
145
- if retries < max_retries
146
- @backoff.call(retries)
147
- retries += 1
148
- retry
149
- else
150
- raise
151
- end
205
+ rescue *error_classes => _e
206
+ raise unless retries < max_retries
207
+
208
+ @backoff.call(retries)
209
+ retries += 1
210
+ retry
152
211
  end
153
212
  end
154
-
155
213
  end
156
214
  end
@@ -2,6 +2,11 @@
2
2
 
3
3
  module Aws
4
4
  module Endpoints
5
+ # This class is deprecated. It is used by the Runtime endpoint
6
+ # resolution approach. It has been replaced by a code generated
7
+ # approach in each service gem. It can be removed in a new
8
+ # major version. It has to exist because
9
+ # old service gems can use a new core version.
5
10
  # @api private
6
11
  class Condition
7
12
  def initialize(fn:, argv:, assign: nil)
@@ -2,7 +2,11 @@
2
2
 
3
3
  module Aws
4
4
  module Endpoints
5
- # @api private
5
+ # This class is deprecated. It is used by the Runtime endpoint
6
+ # resolution approach. It has been replaced by a code generated
7
+ # approach in each service gem. It can be removed in a new
8
+ # major version. It has to exist because
9
+ # old service gems can use a new core version. # @api private
6
10
  class EndpointRule < Rule
7
11
  def initialize(type: 'endpoint', conditions:, endpoint:,
8
12
  documentation: nil)
@@ -2,6 +2,11 @@
2
2
 
3
3
  module Aws
4
4
  module Endpoints
5
+ # This class is deprecated. It is used by the Runtime endpoint
6
+ # resolution approach. It has been replaced by a code generated
7
+ # approach in each service gem. It can be removed in a new
8
+ # major version. It has to exist because
9
+ # old service gems can use a new core version.
5
10
  # @api private
6
11
  class ErrorRule < Rule
7
12
  def initialize(type: 'error', conditions:, error: nil, documentation: nil)
@@ -2,6 +2,11 @@
2
2
 
3
3
  module Aws
4
4
  module Endpoints
5
+ # This class is deprecated. It is used by the Runtime endpoint
6
+ # resolution approach. It has been replaced by a code generated
7
+ # approach in each service gem. It can be removed in a new
8
+ # major version. It has to exist because
9
+ # old service gems can use a new core version.
5
10
  # @api private
6
11
  class Function
7
12
  def initialize(fn:, argv:)
@@ -2,6 +2,11 @@
2
2
 
3
3
  module Aws
4
4
  module Endpoints
5
+ # This class is deprecated. It is used by the Runtime endpoint
6
+ # resolution approach. It has been replaced by a code generated
7
+ # approach in each service gem. It can be removed in a new
8
+ # major version. It has to exist because
9
+ # old service gems can use a new core version.
5
10
  # @api private
6
11
  class Reference
7
12
  def initialize(ref:)
@@ -2,6 +2,11 @@
2
2
 
3
3
  module Aws
4
4
  module Endpoints
5
+ # This class is deprecated. It is used by the Runtime endpoint
6
+ # resolution approach. It has been replaced by a code generated
7
+ # approach in each service gem. It can be removed in a new
8
+ # major version. It has to exist because
9
+ # old service gems can use a new core version.
5
10
  # @api private
6
11
  class Rule
7
12
  # Resolves a value that is a function, reference, or template string.
@@ -2,6 +2,11 @@
2
2
 
3
3
  module Aws
4
4
  module Endpoints
5
+ # This class is deprecated. It is used by the Runtime endpoint
6
+ # resolution approach. It has been replaced by a code generated
7
+ # approach in each service gem. It can be removed in a new
8
+ # major version. It has to exist because
9
+ # old service gems can use a new core version.
5
10
  # @api private
6
11
  class RuleSet
7
12
  def initialize(version:, service_id:, parameters:, rules:)
@@ -1,5 +1,10 @@
1
1
  module Aws
2
2
  module Endpoints
3
+ # This class is deprecated. It is used by the Runtime endpoint
4
+ # resolution approach. It has been replaced by a code generated
5
+ # approach in each service gem. It can be removed in a new
6
+ # major version. It has to exist because
7
+ # old service gems can use a new core version.
3
8
  # @api private
4
9
  class RulesProvider
5
10
  def initialize(rule_set)
@@ -3,6 +3,12 @@
3
3
  module Aws
4
4
  module Endpoints
5
5
  # Does substitutions for templated endpoint strings
6
+
7
+ # This class is deprecated. It is used by the Runtime endpoint
8
+ # resolution approach. It has been replaced by a code generated
9
+ # approach in each service gem. It can be removed in a new
10
+ # major version. It has to exist because
11
+ # old service gems can use a new core version.
6
12
  # @api private
7
13
  module Templater
8
14
  class << self
@@ -2,6 +2,11 @@
2
2
 
3
3
  module Aws
4
4
  module Endpoints
5
+ # This class is deprecated. It is used by the Runtime endpoint
6
+ # resolution approach. It has been replaced by a code generated
7
+ # approach in each service gem. It can be removed in a new
8
+ # major version. It has to exist because
9
+ # old service gems can use a new core version.
5
10
  # @api private
6
11
  class TreeRule
7
12
  def initialize(type: 'tree', conditions:, rules:, documentation: nil)
@@ -4,6 +4,7 @@ require 'ipaddr'
4
4
 
5
5
  module Aws
6
6
  module Endpoints
7
+
7
8
  # @api private
8
9
  class URL
9
10
  def initialize(url)
@@ -26,11 +26,13 @@ module Aws
26
26
  end
27
27
 
28
28
  def error_code(json, context)
29
- code = if aws_query_error?(context)
30
- context.http_response.headers['x-amzn-query-error'].split(';')[0]
31
- else
32
- json['__type']
33
- end
29
+ code =
30
+ if aws_query_error?(context)
31
+ error = context.http_response.headers['x-amzn-query-error'].split(';')[0]
32
+ remove_prefix(error, context)
33
+ else
34
+ json['__type']
35
+ end
34
36
  code ||= json['code']
35
37
  code ||= context.http_response.headers['x-amzn-errortype']
36
38
  if code
@@ -45,6 +47,14 @@ module Aws
45
47
  context.http_response.headers['x-amzn-query-error']
46
48
  end
47
49
 
50
+ def remove_prefix(error_code, context)
51
+ if prefix = context.config.api.metadata['errorPrefix']
52
+ error_code.sub(/^#{prefix}/, '')
53
+ else
54
+ error_code
55
+ end
56
+ end
57
+
48
58
  def error_message(code, json)
49
59
  if code == 'RequestEntityTooLarge'
50
60
  'Request body must be less than 1 MB'
@@ -26,6 +26,8 @@ module Aws
26
26
  #
27
27
  # You can put any of these placeholders into you pattern.
28
28
  #
29
+ # * `:region` - The region configured for the client.
30
+ #
29
31
  # * `:client_class` - The name of the client class.
30
32
  #
31
33
  # * `:operation` - The name of the client request method.
@@ -116,6 +118,10 @@ module Aws
116
118
 
117
119
  private
118
120
 
121
+ def _region(response)
122
+ response.context.config.region
123
+ end
124
+
119
125
  def _client_class(response)
120
126
  response.context.client.class.name
121
127
  end
@@ -201,7 +201,9 @@ module Aws
201
201
  def next_response(params)
202
202
  params = next_page_params(params)
203
203
  request = context.client.build_request(context.operation_name, params)
204
- request.send_request
204
+ Aws::Plugins::UserAgent.feature('paginator') do
205
+ request.send_request
206
+ end
205
207
  end
206
208
 
207
209
  def next_page_params(params)
@@ -314,7 +314,7 @@ module Aws
314
314
  @io.rewind
315
315
  end
316
316
 
317
- def read(length, buf)
317
+ def read(length, buf = nil)
318
318
  # account for possible leftover bytes at the end, if we have trailer bytes, send them
319
319
  if @trailer_io
320
320
  return @trailer_io.read(length, buf)
@@ -39,7 +39,8 @@ module Aws
39
39
 
40
40
  CHECKSUM_ERRORS = Set.new(
41
41
  [
42
- 'CRC32CheckFailed' # dynamodb
42
+ 'CRC32CheckFailed', # dynamodb
43
+ 'BadDigest' # s3
43
44
  ]
44
45
  )
45
46
 
@@ -37,15 +37,25 @@ module Aws
37
37
 
38
38
  class Handler < Seahorse::Client::Handler
39
39
  def call(context)
40
- signer = Sign.signer_for(
41
- context[:auth_scheme],
42
- context.config,
43
- context[:sigv4_region]
44
- )
45
-
46
- signer.sign(context)
40
+ # Skip signing if using sigv2 signing from s3_signer in S3
41
+ unless v2_signing?(context.config)
42
+ signer = Sign.signer_for(
43
+ context[:auth_scheme],
44
+ context.config,
45
+ context[:sigv4_region]
46
+ )
47
+ signer.sign(context)
48
+ end
47
49
  @handler.call(context)
48
50
  end
51
+
52
+ private
53
+
54
+ def v2_signing?(config)
55
+ # 's3' is legacy signing, 'v4' is default
56
+ config.respond_to?(:signature_version) &&
57
+ config.signature_version == 's3'
58
+ end
49
59
  end
50
60
 
51
61
  # @api private