aws-sdk-core 3.232.0 → 3.246.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.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +126 -0
  3. data/VERSION +1 -1
  4. data/lib/aws-sdk-core/assume_role_credentials.rb +8 -8
  5. data/lib/aws-sdk-core/assume_role_web_identity_credentials.rb +2 -2
  6. data/lib/aws-sdk-core/client_stubs.rb +6 -0
  7. data/lib/aws-sdk-core/credential_provider_chain.rb +71 -22
  8. data/lib/aws-sdk-core/ecs_credentials.rb +25 -15
  9. data/lib/aws-sdk-core/errors.rb +3 -0
  10. data/lib/aws-sdk-core/instance_profile_credentials.rb +21 -11
  11. data/lib/aws-sdk-core/login_credentials.rb +230 -0
  12. data/lib/aws-sdk-core/plugins/checksum_algorithm.rb +147 -76
  13. data/lib/aws-sdk-core/plugins/retries/clock_skew.rb +28 -16
  14. data/lib/aws-sdk-core/plugins/user_agent.rb +5 -1
  15. data/lib/aws-sdk-core/refreshing_credentials.rb +8 -11
  16. data/lib/aws-sdk-core/shared_config.rb +20 -0
  17. data/lib/aws-sdk-core/sso_credentials.rb +1 -1
  18. data/lib/aws-sdk-core/sso_token_provider.rb +1 -0
  19. data/lib/aws-sdk-core/waiters/poller.rb +2 -2
  20. data/lib/aws-sdk-core.rb +4 -0
  21. data/lib/aws-sdk-signin/client.rb +604 -0
  22. data/lib/aws-sdk-signin/client_api.rb +119 -0
  23. data/lib/aws-sdk-signin/customizations.rb +1 -0
  24. data/lib/aws-sdk-signin/endpoint_parameters.rb +69 -0
  25. data/lib/aws-sdk-signin/endpoint_provider.rb +59 -0
  26. data/lib/aws-sdk-signin/endpoints.rb +20 -0
  27. data/lib/aws-sdk-signin/errors.rb +122 -0
  28. data/lib/aws-sdk-signin/plugins/endpoints.rb +77 -0
  29. data/lib/aws-sdk-signin/resource.rb +26 -0
  30. data/lib/aws-sdk-signin/types.rb +299 -0
  31. data/lib/aws-sdk-signin.rb +63 -0
  32. data/lib/aws-sdk-sso/client.rb +1 -1
  33. data/lib/aws-sdk-sso/endpoint_parameters.rb +4 -4
  34. data/lib/aws-sdk-sso.rb +1 -1
  35. data/lib/aws-sdk-ssooidc/client.rb +20 -7
  36. data/lib/aws-sdk-ssooidc/client_api.rb +5 -0
  37. data/lib/aws-sdk-ssooidc/endpoint_parameters.rb +4 -4
  38. data/lib/aws-sdk-ssooidc/errors.rb +10 -0
  39. data/lib/aws-sdk-ssooidc/types.rb +27 -15
  40. data/lib/aws-sdk-ssooidc.rb +1 -1
  41. data/lib/aws-sdk-sts/client.rb +136 -12
  42. data/lib/aws-sdk-sts/client_api.rb +73 -1
  43. data/lib/aws-sdk-sts/customizations.rb +0 -1
  44. data/lib/aws-sdk-sts/endpoint_parameters.rb +5 -5
  45. data/lib/aws-sdk-sts/errors.rb +64 -0
  46. data/lib/aws-sdk-sts/types.rb +175 -6
  47. data/lib/aws-sdk-sts.rb +1 -1
  48. data/lib/seahorse/client/h2/handler.rb +6 -1
  49. data/lib/seahorse/client/net_http/patches.rb +44 -11
  50. metadata +13 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ecdbb0ca615cde813f52b03861d36db189562c896e01499ed8dcd80768085300
4
- data.tar.gz: 5ab8e9d52d9f7522afa27ff7c5c6e5e51f27f966ddba8bea62edb153307120c9
3
+ metadata.gz: f922871acf444deaef9037c130a6f9f5b85c42ea8244728aa863cdc00d529105
4
+ data.tar.gz: 23557f7949f3a6df2c7b50322d91fc5a4a4362e79c685553e2cb57ce04d93e19
5
5
  SHA512:
6
- metadata.gz: b23f5bc51a113cfb8b6c0f7306d42c97872d2eff0c5fa0b395b9e714045c8a3446e91313d6d17317419520229ea809097e3abb794f2f448bd698ec982841032f
7
- data.tar.gz: a02785a5b072cb04d27203fb6e990cfa01b10c59f8abdb221b0181b4d07d56a04d0bcc67f308a10fbeba0f3facdadabb77918815e10dbcd8629df25a6d41cc42
6
+ metadata.gz: 0574045e0ec195f54aa84ce917e3d1e64cca6063f6114d10b3daf15e7aebd8734de3a79c0d3d6d6676c0810a136d0c6c662293a9935bf769875a6408213565f9
7
+ data.tar.gz: d526ae465f9ddc6f954526bf75459143def62a1c87f7551d0979650ff7dc10b12a00f666acc5da63a23f7f4e22d588891b56079ad9c202eb97281876f6dd1937
data/CHANGELOG.md CHANGED
@@ -1,6 +1,132 @@
1
1
  Unreleased Changes
2
2
  ------------------
3
3
 
4
+ 3.246.0 (2026-04-23)
5
+ ------------------
6
+
7
+ * Feature - Updated configuration values for `defaults_mode`.
8
+
9
+ 3.245.0 (2026-04-17)
10
+ ------------------
11
+
12
+ * Feature - Updated Aws::STS::Client with the latest API changes.
13
+
14
+ * Feature - The STS client now supports configuring SigV4a through the auth scheme preference setting. SigV4a uses asymmetric cryptography, enabling customers using long-term IAM credentials to continue making STS API calls even when a region is isolated from the partition leader.
15
+
16
+ * Issue - Explicitly set 0600 permissions on SSO/login cache files.
17
+
18
+ 3.244.0 (2026-03-18)
19
+ ------------------
20
+
21
+ * Feature - Support waiter error matcher to handle both boolean and boolean-string acceptors.
22
+
23
+ 3.243.0 (2026-03-05)
24
+ ------------------
25
+
26
+ * Feature - Add user agent metrics for S3 Transfer Manager directory operations.
27
+
28
+ 3.242.0 (2026-02-02)
29
+ ------------------
30
+
31
+ * Feature - Include HTTP status code and body in errors whehn retrieving ECS credentials and Instance Profile credentials.
32
+
33
+ 3.241.4 (2026-01-16)
34
+ ------------------
35
+
36
+ * Issue - Rewind IO during initialization for `AwsChunkedTrailerDigestIO`.
37
+
38
+ 3.241.3 (2026-01-08)
39
+ ------------------
40
+
41
+ * Issue - Disable request trailer checksums when using non-HTTPs endpoints.
42
+
43
+ 3.241.2 (2026-01-07)
44
+ ------------------
45
+
46
+ * Issue - Preserve existing Content-Encoding when applying request trailer checksum.
47
+
48
+ 3.241.1 (2026-01-06)
49
+ ------------------
50
+
51
+ * Issue - Fix memory leak in ClockSkew retry plugin by normalizing endpoints to prevent unlimited hash growth.
52
+
53
+ 3.241.0 (2026-01-05)
54
+ ------------------
55
+
56
+ * Feature - Improved memory efficiency when calculating request checksums.
57
+
58
+ 3.240.0 (2025-12-16)
59
+ ------------------
60
+
61
+ * Feature - Updated configuration values for `defaults_mode`.
62
+
63
+ * Issue - Prioritizes JSON over CBOR when both are supported for stubbed clients.
64
+
65
+ 3.239.2 (2025-11-25)
66
+ ------------------
67
+
68
+ * Issue - Fix `login_credentials` in credentials chain when config is enabled.
69
+
70
+ 3.239.1 (2025-11-21)
71
+ ------------------
72
+
73
+ * Issue - Fixed HTTP/2 connection issues when using custom ports.
74
+
75
+ 3.239.0 (2025-11-20)
76
+ ------------------
77
+
78
+ * Feature - Updated Aws::Signin::Client with the latest API changes.
79
+
80
+ * Issue - Fix region configuration for LoginCredential's Signin client.
81
+
82
+ 3.238.0 (2025-11-19)
83
+ ------------------
84
+
85
+ * Feature - Updated Aws::Signin::Client with the latest API changes.
86
+
87
+ * Feature - Updated Aws::STS::Client with the latest API changes.
88
+
89
+ * Feature - IAM now supports outbound identity federation via the STS GetWebIdentityToken API, enabling AWS workloads to securely authenticate with external services using short-lived JSON Web Tokens.
90
+
91
+ * Feature - Add `LoginCredentials` which retrieves credentials from AWS Sign-In. Support `aws-sdk-signin` alias gem.
92
+
93
+ 3.237.0 (2025-11-10)
94
+ ------------------
95
+
96
+ * Feature - Updated Aws::STS::Client with the latest API changes.
97
+
98
+ * Feature - Added GetDelegatedAccessToken API, which is not available for general use at this time.
99
+
100
+ 3.236.0 (2025-10-30)
101
+ ------------------
102
+
103
+ * Feature - Updated Aws::STS::Client with the latest API changes.
104
+
105
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
106
+
107
+ * Feature - Update endpoint ruleset parameters casing
108
+
109
+ 3.235.0 (2025-10-24)
110
+ ------------------
111
+
112
+ * Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
113
+
114
+ * Feature - Update endpoint ruleset parameters casing
115
+
116
+ 3.234.0 (2025-10-21)
117
+ ------------------
118
+
119
+ * Issue - Fix `request_checksum_calculation` `when_required` mode to only calculate checksums when explicitly provided by user.
120
+
121
+ * Feature - Add `CREDENTIALS_CODE` metric for `static_profile_` prefixed methods in default credential chain.
122
+
123
+ 3.233.0 (2025-09-23)
124
+ ------------------
125
+
126
+ * Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
127
+
128
+ * Feature - This release includes exception definition and documentation updates.
129
+
4
130
  3.232.0 (2025-08-28)
5
131
  ------------------
6
132
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.232.0
1
+ 3.246.0
@@ -7,7 +7,7 @@ module Aws
7
7
  # {Aws::STS::Client#assume_role}.
8
8
  #
9
9
  # role_credentials = Aws::AssumeRoleCredentials.new(
10
- # client: Aws::STS::Client.new(...),
10
+ # client: Aws::STS::Client.new(sts_options),
11
11
  # role_arn: "linked::account::arn",
12
12
  # role_session_name: "session-name"
13
13
  # )
@@ -28,15 +28,15 @@ module Aws
28
28
  # @option options [Integer] :duration_seconds
29
29
  # @option options [String] :external_id
30
30
  # @option options [STS::Client] :client
31
- # @option options [Callable] before_refresh Proc called before
31
+ # @option options [Proc] :before_refresh A Proc called before
32
32
  # credentials are refreshed. Useful for updating tokens.
33
- # `before_refresh` is called when AWS credentials are
34
- # required and need to be refreshed. Tokens can be refreshed using
35
- # the following example:
33
+ # `:before_refresh` is called when AWS credentials are
34
+ # required and need to be refreshed. See the example in this doc.
36
35
  #
37
- # before_refresh = Proc.new do |assume_role_credentials| do
38
- # assume_role_credentials.assume_role_params['token_code'] = update_token
39
- # end
36
+ # @example Tokens can be refreshed using a Proc.
37
+ # before_refresh = Proc.new do |assume_role_credentials|
38
+ # assume_role_credentials.assume_role_params['token_code'] = update_token
39
+ # end
40
40
  #
41
41
  def initialize(options = {})
42
42
  client_opts = {}
@@ -9,11 +9,11 @@ module Aws
9
9
  # {Aws::STS::Client#assume_role_with_web_identity}.
10
10
  #
11
11
  # role_credentials = Aws::AssumeRoleWebIdentityCredentials.new(
12
- # client: Aws::STS::Client.new(...),
12
+ # client: Aws::STS::Client.new(sts_options),
13
13
  # role_arn: "linked::account::arn",
14
14
  # web_identity_token_file: "/path/to/token/file",
15
15
  # role_session_name: "session-name"
16
- # ...
16
+ # # ...
17
17
  # )
18
18
  # ec2 = Aws::EC2::Client.new(credentials: role_credentials)
19
19
  #
@@ -280,6 +280,12 @@ module Aws
280
280
  end
281
281
 
282
282
  def protocol_helper
283
+ # Prioritize JSON over CBOR when CBOR is the configured protocol but both are supported. This is to match similar
284
+ # prioritization in service.rb code generation.
285
+ if @config.api.metadata['protocol'] == 'smithy-rpc-v2-cbor' && @config.api.metadata['protocols']&.include?('json')
286
+ return Stubbing::Protocols::Json.new
287
+ end
288
+
283
289
  case @config.api.metadata['protocol']
284
290
  when 'json' then Stubbing::Protocols::Json
285
291
  when 'rest-json' then Stubbing::Protocols::RestJson
@@ -11,7 +11,7 @@ module Aws
11
11
  def resolve
12
12
  providers.each do |method_name, options|
13
13
  provider = send(method_name, options.merge(config: @config))
14
- return provider if provider && provider.set?
14
+ return provider if provider&.set?
15
15
  end
16
16
  nil
17
17
  end
@@ -25,12 +25,14 @@ module Aws
25
25
  [:static_profile_sso_credentials, {}],
26
26
  [:static_profile_assume_role_credentials, {}],
27
27
  [:static_profile_credentials, {}],
28
+ [:static_profile_login_credentials, {}],
28
29
  [:static_profile_process_credentials, {}],
29
30
  [:env_credentials, {}],
30
31
  [:assume_role_web_identity_credentials, {}],
31
32
  [:sso_credentials, {}],
32
33
  [:assume_role_credentials, {}],
33
34
  [:shared_credentials, {}],
35
+ [:login_credentials, {}],
34
36
  [:process_credentials, {}],
35
37
  [:instance_profile_credentials, {
36
38
  retries: @config ? @config.instance_profile_credentials_retries : 0,
@@ -54,47 +56,80 @@ module Aws
54
56
  end
55
57
 
56
58
  def static_profile_assume_role_web_identity_credentials(options)
57
- if Aws.shared_config.config_enabled? && options[:config] && options[:config].profile
58
- Aws.shared_config.assume_role_web_identity_credentials_from_config(
59
+ return unless Aws.shared_config.config_enabled? && options[:config]&.profile
60
+
61
+ with_metrics('CREDENTIALS_CODE') do
62
+ creds = Aws.shared_config.assume_role_web_identity_credentials_from_config(
59
63
  profile: options[:config].profile,
60
64
  region: options[:config].region
61
65
  )
66
+ return unless creds
67
+
68
+ creds.metrics << 'CREDENTIALS_CODE'
69
+ creds
62
70
  end
63
71
  end
64
72
 
65
73
  def static_profile_sso_credentials(options)
66
- if Aws.shared_config.config_enabled? && options[:config] && options[:config].profile
67
- Aws.shared_config.sso_credentials_from_config(
74
+ return unless Aws.shared_config.config_enabled? && options[:config]&.profile
75
+
76
+ with_metrics('CREDENTIALS_CODE') do
77
+ creds = Aws.shared_config.sso_credentials_from_config(
68
78
  profile: options[:config].profile
69
79
  )
80
+ return unless creds
81
+
82
+ creds.metrics << 'CREDENTIALS_CODE'
83
+ creds
70
84
  end
71
85
  end
72
86
 
73
87
  def static_profile_assume_role_credentials(options)
74
- if Aws.shared_config.config_enabled? && options[:config] && options[:config].profile
75
- assume_role_with_profile(options, options[:config].profile)
88
+ return unless Aws.shared_config.config_enabled? && options[:config]&.profile
89
+
90
+ with_metrics('CREDENTIALS_CODE') do
91
+ creds = assume_role_with_profile(options, options[:config].profile)
92
+ return unless creds
93
+
94
+ creds.metrics << 'CREDENTIALS_CODE'
95
+ creds
76
96
  end
77
97
  end
78
98
 
79
99
  def static_profile_credentials(options)
80
- if options[:config] && options[:config].profile
81
- creds = SharedCredentials.new(profile_name: options[:config].profile)
82
- creds.metrics = ['CREDENTIALS_PROFILE']
83
- creds
84
- end
100
+ return unless options[:config]&.profile
101
+
102
+ creds = SharedCredentials.new(profile_name: options[:config].profile)
103
+ creds.metrics << 'CREDENTIALS_PROFILE'
104
+ creds
85
105
  rescue Errors::NoSuchProfileError
86
106
  nil
87
107
  end
88
108
 
89
- def static_profile_process_credentials(options)
90
- if Aws.shared_config.config_enabled? && options[:config] && options[:config].profile
91
- process_provider = Aws.shared_config.credential_process(profile: options[:config].profile)
92
- if process_provider
93
- creds = ProcessCredentials.new([process_provider])
94
- creds.metrics << 'CREDENTIALS_PROFILE_PROCESS'
95
- creds
96
- end
109
+ def static_profile_login_credentials(options)
110
+ return unless Aws.shared_config.config_enabled? && options[:config]&.profile
111
+
112
+ with_metrics('CREDENTIALS_CODE') do
113
+ creds = Aws.shared_config.login_credentials_from_config(
114
+ profile: options[:config].profile,
115
+ region: options[:config].region
116
+ )
117
+ return unless creds
118
+
119
+ creds.metrics << 'CREDENTIALS_CODE'
120
+ creds
97
121
  end
122
+ end
123
+
124
+ def static_profile_process_credentials(options)
125
+ return unless Aws.shared_config.config_enabled? && options[:config]&.profile
126
+
127
+ process_provider = Aws.shared_config.credential_process(profile: options[:config].profile)
128
+ return unless process_provider
129
+
130
+ creds = ProcessCredentials.new([process_provider])
131
+ creds.metrics.concat(%w[CREDENTIALS_PROFILE_PROCESS CREDENTIALS_CODE])
132
+ creds
98
133
  rescue Errors::NoSuchProfileError
99
134
  nil
100
135
  end
@@ -122,7 +157,7 @@ module Aws
122
157
  end
123
158
 
124
159
  def determine_profile_name(options)
125
- (options[:config] && options[:config].profile) || ENV['AWS_PROFILE'] || ENV['AWS_DEFAULT_PROFILE'] || 'default'
160
+ (options[:config]&.profile) || ENV['AWS_PROFILE'] || ENV['AWS_DEFAULT_PROFILE'] || 'default'
126
161
  end
127
162
 
128
163
  def shared_credentials(options)
@@ -134,6 +169,16 @@ module Aws
134
169
  nil
135
170
  end
136
171
 
172
+ def login_credentials(options)
173
+ return unless Aws.shared_config.config_enabled?
174
+
175
+ profile_name = determine_profile_name(options)
176
+ region = options[:config].region if options[:config]
177
+ Aws.shared_config.login_credentials_from_config(profile: profile_name, region: region)
178
+ rescue Errors::NoSuchProfileError
179
+ nil
180
+ end
181
+
137
182
  def process_credentials(options)
138
183
  profile_name = determine_profile_name(options)
139
184
  if Aws.shared_config.config_enabled?
@@ -201,10 +246,14 @@ module Aws
201
246
  profile: profile_name,
202
247
  chain_config: @config
203
248
  }
204
- if options[:config] && options[:config].region
249
+ if options[:config]&.region
205
250
  assume_opts[:region] = options[:config].region
206
251
  end
207
252
  Aws.shared_config.assume_role_credentials_from_config(assume_opts)
208
253
  end
254
+
255
+ def with_metrics(metrics, &block)
256
+ Aws::Plugins::UserAgent.metric(*metrics, &block)
257
+ end
209
258
  end
210
259
  end
@@ -15,7 +15,17 @@ module Aws
15
15
  include RefreshingCredentials
16
16
 
17
17
  # @api private
18
- class Non200Response < RuntimeError; end
18
+ class Non200Response < RuntimeError
19
+ attr_reader :status_code, :body
20
+
21
+ def initialize(status_code, body = nil)
22
+ @status_code = status_code
23
+ @body = body
24
+ msg = "HTTP #{status_code}"
25
+ msg += ": #{body}" if body && !body.empty?
26
+ super(msg)
27
+ end
28
+ end
19
29
 
20
30
  # Raised when the token file cannot be read.
21
31
  class TokenFileReadError < RuntimeError; end
@@ -42,26 +52,26 @@ module Aws
42
52
  # @option options [Integer] :retries (5) Number of times to retry
43
53
  # when retrieving credentials.
44
54
  # @option options [String] :ip_address ('169.254.170.2') This value is
45
- # ignored if `endpoint` is set and `credential_path` is not set.
46
- # @option options [Integer] :port (80) This value is ignored if `endpoint`
47
- # is set and `credential_path` is not set.
55
+ # ignored if `:endpoint` is set and `:credential_path` is not set.
56
+ # @option options [Integer] :port (80) This value is ignored if `:endpoint`
57
+ # is set and `:credential_path` is not set.
48
58
  # @option options [String] :credential_path By default, the value of the
49
- # AWS_CONTAINER_CREDENTIALS_RELATIVE_URI environment variable.
59
+ # `AWS_CONTAINER_CREDENTIALS_RELATIVE_URI` environment variable.
50
60
  # @option options [String] :endpoint The container credential endpoint.
51
- # By default, this is the value of the AWS_CONTAINER_CREDENTIALS_FULL_URI
52
- # environment variable. This value is ignored if `credential_path` or
53
- # ENV['AWS_CONTAINER_CREDENTIALS_RELATIVE_URI'] is set.
61
+ # By default, this is the value of the `AWS_CONTAINER_CREDENTIALS_FULL_URI`
62
+ # environment variable. This value is ignored if `:credential_path` or
63
+ # `ENV['AWS_CONTAINER_CREDENTIALS_RELATIVE_URI']` is set.
54
64
  # @option options [Float] :http_open_timeout (5)
55
65
  # @option options [Float] :http_read_timeout (5)
56
- # @option options [Numeric, Proc] :delay By default, failures are retried
66
+ # @option options [IO] :http_debug_output (nil) HTTP wire
67
+ # traces are sent to this object. You can specify something
68
+ # like `$stdout`.
69
+ # @option options [Numeric, Proc] :backoff By default, failures are retried
57
70
  # with exponential back-off, i.e. `sleep(1.2 ** num_failures)`. You can
58
71
  # pass a number of seconds to sleep between failed attempts, or
59
72
  # a Proc that accepts the number of failures.
60
- # @option options [IO] :http_debug_output (nil) HTTP wire
61
- # traces are sent to this object. You can specify something
62
- # like $stdout.
63
- # @option options [Callable] before_refresh Proc called before
64
- # credentials are refreshed. `before_refresh` is called
73
+ # @option options [Proc] :before_refresh A Proc called before
74
+ # credentials are refreshed. `:before_refresh` is called
65
75
  # with an instance of this object when
66
76
  # AWS credentials are required and need to be refreshed.
67
77
  def initialize(options = {})
@@ -251,7 +261,7 @@ module Aws
251
261
  request = Net::HTTP::Get.new(path)
252
262
  set_authorization_token(request)
253
263
  response = connection.request(request)
254
- raise Non200Response unless response.code.to_i == 200
264
+ raise Non200Response.new(response.code.to_i, response.body) unless response.code.to_i == 200
255
265
 
256
266
  response.body
257
267
  end
@@ -213,6 +213,9 @@ module Aws
213
213
  # Raised when SSO Token is invalid
214
214
  class InvalidSSOToken < RuntimeError; end
215
215
 
216
+ # Raised when Login Token is invalid
217
+ class InvalidLoginToken < RuntimeError; end
218
+
216
219
  # Raised when a client is unable to sign a request because
217
220
  # the bearer token is not configured or available
218
221
  class MissingBearerTokenError < RuntimeError
@@ -26,7 +26,17 @@ module Aws
26
26
  include RefreshingCredentials
27
27
 
28
28
  # @api private
29
- class Non200Response < RuntimeError; end
29
+ class Non200Response < RuntimeError
30
+ attr_reader :status_code, :body
31
+
32
+ def initialize(status_code, body = nil)
33
+ @status_code = status_code
34
+ @body = body
35
+ msg = "HTTP #{status_code}"
36
+ msg += ": #{body}" if body && !body.empty?
37
+ super(msg)
38
+ end
39
+ end
30
40
 
31
41
  # @api private
32
42
  class TokenRetrivalError < RuntimeError; end
@@ -57,6 +67,9 @@ module Aws
57
67
 
58
68
  # @param [Hash] options
59
69
  # @option options [Integer] :retries (1) Number of times to retry when retrieving credentials.
70
+ # @option options [Numeric, Proc] :backoff By default, failures are retried with exponential back-off, i.e.
71
+ # `lambda { |num_failures| sleep(1.2 ** num_failures) }`. You can pass a number of seconds to sleep
72
+ # between failed attempts, or a Proc that accepts the number of failures.
60
73
  # @option options [String] :endpoint ('http://169.254.169.254') The IMDS endpoint. This option has precedence
61
74
  # over the `:endpoint_mode`.
62
75
  # @option options [String] :endpoint_mode ('IPv4') The endpoint mode for the instance metadata service. This is
@@ -67,14 +80,11 @@ module Aws
67
80
  # @option options [Integer] :port (80)
68
81
  # @option options [Float] :http_open_timeout (1)
69
82
  # @option options [Float] :http_read_timeout (1)
70
- # @option options [Numeric, Proc] :delay By default, failures are retried with exponential back-off, i.e.
71
- # `sleep(1.2 ** num_failures)`. You can pass a number of seconds to sleep between failed attempts, or a Proc
72
- # that accepts the number of failures.
73
83
  # @option options [IO] :http_debug_output (nil) HTTP wire traces are sent to this object.
74
84
  # You can specify something like `$stdout`.
75
- # @option options [Integer] :token_ttl Time-to-Live in seconds for EC2 Metadata Token used for fetching
76
- # Metadata Profile Credentials, defaults to 21600 seconds.
77
- # @option options [Callable] :before_refresh Proc called before credentials are refreshed. `before_refresh`
85
+ # @option options [Integer] :token_ttl (21600) Time-to-Live in seconds for EC2 Metadata Token used for fetching
86
+ # Metadata Profile Credentials.
87
+ # @option options [Proc] :before_refresh A Proc called before credentials are refreshed. `:before_refresh`
78
88
  # is called with an instance of this object when AWS credentials are required and need to be refreshed.
79
89
  def initialize(options = {})
80
90
  @backoff = resolve_backoff(options[:backoff])
@@ -95,7 +105,7 @@ module Aws
95
105
  super
96
106
  end
97
107
 
98
- # @return [Boolean0
108
+ # @return [Boolean]
99
109
  attr_reader :disable_imds_v1
100
110
 
101
111
  # @return [Integer]
@@ -249,7 +259,7 @@ module Aws
249
259
  # The next retry should fetch it
250
260
  @token = nil
251
261
  @imds_v1_fallback = false
252
- raise Non200Response
262
+ raise Non200Response.new(401, 'Token expired')
253
263
  end
254
264
 
255
265
  def token_set?
@@ -278,7 +288,7 @@ module Aws
278
288
  when 401
279
289
  raise TokenExpiredError
280
290
  else
281
- raise Non200Response
291
+ raise Non200Response.new(response.code.to_i, response.body)
282
292
  end
283
293
  end
284
294
 
@@ -298,7 +308,7 @@ module Aws
298
308
  when 400
299
309
  raise TokenRetrivalError
300
310
  else
301
- raise Non200Response
311
+ raise Non200Response.new(response.code.to_i, response.body)
302
312
  end
303
313
  end
304
314