aws-sdk-core 3.197.2 → 3.225.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 (150) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +355 -0
  3. data/VERSION +1 -1
  4. data/lib/aws-defaults/default_configuration.rb +1 -2
  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 +13 -5
  8. data/lib/aws-sdk-core/assume_role_web_identity_credentials.rb +14 -7
  9. data/lib/aws-sdk-core/binary/decode_handler.rb +3 -4
  10. data/lib/aws-sdk-core/binary/encode_handler.rb +1 -1
  11. data/lib/aws-sdk-core/binary/event_stream_decoder.rb +1 -0
  12. data/lib/aws-sdk-core/binary/event_stream_encoder.rb +4 -3
  13. data/lib/aws-sdk-core/cbor/decoder.rb +308 -0
  14. data/lib/aws-sdk-core/cbor/encoder.rb +243 -0
  15. data/lib/aws-sdk-core/cbor.rb +53 -0
  16. data/lib/aws-sdk-core/client_side_monitoring.rb +9 -0
  17. data/lib/aws-sdk-core/client_stubs.rb +30 -55
  18. data/lib/aws-sdk-core/credential_provider.rb +4 -0
  19. data/lib/aws-sdk-core/credential_provider_chain.rb +37 -10
  20. data/lib/aws-sdk-core/credentials.rb +19 -6
  21. data/lib/aws-sdk-core/ecs_credentials.rb +1 -0
  22. data/lib/aws-sdk-core/endpoints/endpoint.rb +3 -1
  23. data/lib/aws-sdk-core/endpoints/matchers.rb +1 -8
  24. data/lib/aws-sdk-core/endpoints.rb +74 -18
  25. data/lib/aws-sdk-core/error_handler.rb +41 -0
  26. data/lib/aws-sdk-core/errors.rb +11 -2
  27. data/lib/aws-sdk-core/instance_profile_credentials.rb +1 -0
  28. data/lib/aws-sdk-core/json/error_handler.rb +8 -9
  29. data/lib/aws-sdk-core/json/handler.rb +6 -6
  30. data/lib/aws-sdk-core/json/json_engine.rb +3 -1
  31. data/lib/aws-sdk-core/json/oj_engine.rb +7 -1
  32. data/lib/aws-sdk-core/json/parser.rb +2 -0
  33. data/lib/aws-sdk-core/json.rb +43 -14
  34. data/lib/aws-sdk-core/log/param_filter.rb +2 -2
  35. data/lib/aws-sdk-core/log/param_formatter.rb +7 -3
  36. data/lib/aws-sdk-core/log.rb +10 -0
  37. data/lib/aws-sdk-core/param_validator.rb +1 -1
  38. data/lib/aws-sdk-core/plugins/bearer_authorization.rb +2 -0
  39. data/lib/aws-sdk-core/plugins/checksum_algorithm.rb +332 -169
  40. data/lib/aws-sdk-core/plugins/client_metrics_plugin.rb +0 -1
  41. data/lib/aws-sdk-core/plugins/credentials_configuration.rb +7 -3
  42. data/lib/aws-sdk-core/plugins/endpoint_pattern.rb +40 -32
  43. data/lib/aws-sdk-core/plugins/global_configuration.rb +8 -9
  44. data/lib/aws-sdk-core/plugins/http_checksum.rb +2 -8
  45. data/lib/aws-sdk-core/plugins/protocols/api_gateway.rb +3 -1
  46. data/lib/aws-sdk-core/plugins/protocols/ec2.rb +2 -24
  47. data/lib/aws-sdk-core/plugins/protocols/json_rpc.rb +6 -8
  48. data/lib/aws-sdk-core/plugins/protocols/query.rb +4 -2
  49. data/lib/aws-sdk-core/plugins/protocols/rest_json.rb +4 -3
  50. data/lib/aws-sdk-core/plugins/protocols/rest_xml.rb +5 -1
  51. data/lib/aws-sdk-core/plugins/protocols/rpc_v2.rb +17 -0
  52. data/lib/aws-sdk-core/plugins/regional_endpoint.rb +74 -25
  53. data/lib/aws-sdk-core/plugins/retry_errors.rb +0 -1
  54. data/lib/aws-sdk-core/plugins/sign.rb +28 -12
  55. data/lib/aws-sdk-core/plugins/signature_v2.rb +2 -1
  56. data/lib/aws-sdk-core/plugins/signature_v4.rb +2 -1
  57. data/lib/aws-sdk-core/plugins/stub_responses.rb +52 -9
  58. data/lib/aws-sdk-core/plugins/telemetry.rb +75 -0
  59. data/lib/aws-sdk-core/plugins/transfer_encoding.rb +16 -9
  60. data/lib/aws-sdk-core/plugins/user_agent.rb +48 -9
  61. data/lib/aws-sdk-core/plugins.rb +39 -0
  62. data/lib/aws-sdk-core/process_credentials.rb +3 -2
  63. data/lib/aws-sdk-core/query/ec2_handler.rb +27 -0
  64. data/lib/aws-sdk-core/query/handler.rb +4 -4
  65. data/lib/aws-sdk-core/query.rb +2 -1
  66. data/lib/aws-sdk-core/resources.rb +8 -0
  67. data/lib/aws-sdk-core/rest/{request/content_type.rb → content_type_handler.rb} +1 -1
  68. data/lib/aws-sdk-core/rest/handler.rb +3 -4
  69. data/lib/aws-sdk-core/rest/request/headers.rb +3 -3
  70. data/lib/aws-sdk-core/rest.rb +1 -1
  71. data/lib/aws-sdk-core/rpc_v2/builder.rb +62 -0
  72. data/lib/aws-sdk-core/rpc_v2/cbor_engine.rb +18 -0
  73. data/lib/aws-sdk-core/rpc_v2/content_type_handler.rb +47 -0
  74. data/lib/aws-sdk-core/rpc_v2/error_handler.rb +85 -0
  75. data/lib/aws-sdk-core/rpc_v2/handler.rb +79 -0
  76. data/lib/aws-sdk-core/rpc_v2/parser.rb +98 -0
  77. data/lib/aws-sdk-core/rpc_v2.rb +69 -0
  78. data/lib/aws-sdk-core/shared_config.rb +78 -22
  79. data/lib/aws-sdk-core/shared_credentials.rb +1 -7
  80. data/lib/aws-sdk-core/sso_credentials.rb +4 -1
  81. data/lib/aws-sdk-core/stubbing/protocols/ec2.rb +12 -11
  82. data/lib/aws-sdk-core/stubbing/protocols/json.rb +11 -10
  83. data/lib/aws-sdk-core/stubbing/protocols/query.rb +7 -6
  84. data/lib/aws-sdk-core/stubbing/protocols/rest.rb +2 -1
  85. data/lib/aws-sdk-core/stubbing/protocols/rest_json.rb +9 -8
  86. data/lib/aws-sdk-core/stubbing/protocols/rest_xml.rb +6 -5
  87. data/lib/aws-sdk-core/stubbing/protocols/rpc_v2.rb +39 -0
  88. data/lib/aws-sdk-core/stubbing.rb +22 -0
  89. data/lib/aws-sdk-core/telemetry/base.rb +177 -0
  90. data/lib/aws-sdk-core/telemetry/no_op.rb +70 -0
  91. data/lib/aws-sdk-core/telemetry/otel.rb +235 -0
  92. data/lib/aws-sdk-core/telemetry/span_kind.rb +22 -0
  93. data/lib/aws-sdk-core/telemetry/span_status.rb +59 -0
  94. data/lib/aws-sdk-core/telemetry.rb +78 -0
  95. data/lib/aws-sdk-core/waiters/poller.rb +9 -4
  96. data/lib/aws-sdk-core/xml/error_handler.rb +11 -37
  97. data/lib/aws-sdk-core/xml/parser.rb +2 -6
  98. data/lib/aws-sdk-core.rb +82 -108
  99. data/lib/aws-sdk-sso/client.rb +100 -39
  100. data/lib/aws-sdk-sso/client_api.rb +7 -0
  101. data/lib/aws-sdk-sso/endpoint_parameters.rb +9 -6
  102. data/lib/aws-sdk-sso/endpoint_provider.rb +14 -18
  103. data/lib/aws-sdk-sso/endpoints.rb +2 -54
  104. data/lib/aws-sdk-sso/plugins/endpoints.rb +19 -20
  105. data/lib/aws-sdk-sso/types.rb +1 -0
  106. data/lib/aws-sdk-sso.rb +15 -11
  107. data/lib/aws-sdk-ssooidc/client.rb +137 -59
  108. data/lib/aws-sdk-ssooidc/client_api.rb +11 -0
  109. data/lib/aws-sdk-ssooidc/endpoint_parameters.rb +9 -6
  110. data/lib/aws-sdk-ssooidc/endpoint_provider.rb +14 -18
  111. data/lib/aws-sdk-ssooidc/endpoints.rb +2 -54
  112. data/lib/aws-sdk-ssooidc/plugins/endpoints.rb +19 -20
  113. data/lib/aws-sdk-ssooidc/types.rb +49 -16
  114. data/lib/aws-sdk-ssooidc.rb +15 -11
  115. data/lib/aws-sdk-sts/client.rb +308 -91
  116. data/lib/aws-sdk-sts/client_api.rb +36 -10
  117. data/lib/aws-sdk-sts/customizations.rb +5 -1
  118. data/lib/aws-sdk-sts/endpoint_parameters.rb +10 -9
  119. data/lib/aws-sdk-sts/endpoint_provider.rb +50 -55
  120. data/lib/aws-sdk-sts/endpoints.rb +2 -118
  121. data/lib/aws-sdk-sts/errors.rb +16 -0
  122. data/lib/aws-sdk-sts/plugins/endpoints.rb +19 -28
  123. data/lib/aws-sdk-sts/types.rb +171 -28
  124. data/lib/aws-sdk-sts.rb +15 -11
  125. data/lib/seahorse/client/async_base.rb +4 -5
  126. data/lib/seahorse/client/base.rb +17 -21
  127. data/lib/seahorse/client/h2/connection.rb +18 -28
  128. data/lib/seahorse/client/h2/handler.rb +13 -3
  129. data/lib/seahorse/client/handler.rb +1 -1
  130. data/lib/seahorse/client/http/response.rb +1 -1
  131. data/lib/seahorse/client/net_http/connection_pool.rb +10 -2
  132. data/lib/seahorse/client/net_http/handler.rb +21 -9
  133. data/lib/seahorse/client/networking_error.rb +1 -1
  134. data/lib/seahorse/client/plugins/endpoint.rb +0 -1
  135. data/lib/seahorse/client/plugins/h2.rb +4 -4
  136. data/lib/seahorse/client/plugins/net_http.rb +9 -0
  137. data/lib/seahorse/client/request_context.rb +8 -1
  138. data/lib/seahorse/client/response.rb +2 -0
  139. data/sig/aws-sdk-core/async_client_stubs.rbs +21 -0
  140. data/sig/aws-sdk-core/telemetry/base.rbs +46 -0
  141. data/sig/aws-sdk-core/telemetry/otel.rbs +22 -0
  142. data/sig/aws-sdk-core/telemetry/span_kind.rbs +15 -0
  143. data/sig/aws-sdk-core/telemetry/span_status.rbs +24 -0
  144. data/sig/seahorse/client/async_base.rbs +18 -0
  145. metadata +80 -24
  146. /data/lib/aws-sdk-core/xml/parser/{engines/libxml.rb → libxml_engine.rb} +0 -0
  147. /data/lib/aws-sdk-core/xml/parser/{engines/nokogiri.rb → nokogiri_engine.rb} +0 -0
  148. /data/lib/aws-sdk-core/xml/parser/{engines/oga.rb → oga_engine.rb} +0 -0
  149. /data/lib/aws-sdk-core/xml/parser/{engines/ox.rb → ox_engine.rb} +0 -0
  150. /data/lib/aws-sdk-core/xml/parser/{engines/rexml.rb → rexml_engine.rb} +0 -0
@@ -4,62 +4,70 @@ module Aws
4
4
  module Plugins
5
5
  # @api private
6
6
  class EndpointPattern < Seahorse::Client::Plugin
7
-
8
- option(:disable_host_prefix_injection,
7
+ option(
8
+ :disable_host_prefix_injection,
9
9
  default: false,
10
10
  doc_type: 'Boolean',
11
- docstring: <<-DOCS
12
- Set to true to disable SDK automatically adding host prefix
13
- to default service endpoint when available.
14
- DOCS
15
- )
11
+ docstring: 'When `true`, the SDK will not prepend the modeled host prefix to the endpoint.'
12
+ ) do |cfg|
13
+ resolve_disable_host_prefix_injection(cfg)
14
+ end
16
15
 
17
- def add_handlers(handlers, config)
16
+ def add_handlers(handlers, _config)
18
17
  handlers.add(Handler, priority: 10)
19
18
  end
20
19
 
21
- class Handler < Seahorse::Client::Handler
20
+ class << self
21
+ private
22
+
23
+ def resolve_disable_host_prefix_injection(cfg)
24
+ value = ENV['AWS_DISABLE_HOST_PREFIX_INJECTION'] ||
25
+ Aws.shared_config.disable_host_prefix_injection(profile: cfg.profile) ||
26
+ 'false'
27
+ value = Aws::Util.str_2_bool(value)
28
+ unless [true, false].include?(value)
29
+ raise ArgumentError,
30
+ 'Must provide either `true` or `false` for '\
31
+ 'disable_host_prefix_injection profile option or for '\
32
+ 'ENV[\'AWS_DISABLE_HOST_PREFIX_INJECTION\']'
33
+ end
34
+ value
35
+ end
36
+ end
22
37
 
38
+ # @api private
39
+ class Handler < Seahorse::Client::Handler
23
40
  def call(context)
24
- if !context.config.disable_host_prefix_injection
41
+ unless context.config.disable_host_prefix_injection
25
42
  endpoint_trait = context.operation.endpoint_pattern
26
- if endpoint_trait && !endpoint_trait.empty?
27
- _apply_endpoint_trait(context, endpoint_trait)
28
- end
43
+ apply_endpoint_trait(context, endpoint_trait) if endpoint_trait && !endpoint_trait.empty?
29
44
  end
30
45
  @handler.call(context)
31
46
  end
32
47
 
33
48
  private
34
49
 
35
- def _apply_endpoint_trait(context, trait)
36
- # currently only support host pattern
37
- ori_host = context.http_request.endpoint.host
38
- if pattern = trait['hostPrefix']
39
- host_prefix = pattern.gsub(/\{.+?\}/) do |label|
40
- label = label.delete("{}")
41
- _replace_label_value(
42
- ori_host, label, context.operation.input, context.params)
43
- end
44
- context.http_request.endpoint.host = host_prefix + context.http_request.endpoint.host
50
+ def apply_endpoint_trait(context, trait)
51
+ pattern = trait['hostPrefix']
52
+ return unless pattern
53
+
54
+ host_prefix = pattern.gsub(/\{.+?}/) do |label|
55
+ label = label.delete('{}')
56
+ replace_label_value(label, context.operation.input, context.params)
45
57
  end
58
+ context.http_request.endpoint.host = host_prefix + context.http_request.endpoint.host
46
59
  end
47
60
 
48
- def _replace_label_value(ori, label, input_ref, params)
61
+ def replace_label_value(label, input_ref, params)
49
62
  name = nil
50
63
  input_ref.shape.members.each do |m_name, ref|
51
- if ref['hostLabel'] && ref['hostLabelName'] == label
52
- name = m_name
53
- end
54
- end
55
- if name.nil? || params[name].nil?
56
- raise Errors::MissingEndpointHostLabelValue.new(name)
64
+ name = m_name if ref['hostLabel'] && ref['hostLabelName'] == label
57
65
  end
66
+ raise Errors::MissingEndpointHostLabelValue, name if name.nil? || params[name].nil?
67
+
58
68
  params[name]
59
69
  end
60
-
61
70
  end
62
-
63
71
  end
64
72
  end
65
73
  end
@@ -43,7 +43,7 @@ module Aws
43
43
  # @api private
44
44
  class GlobalConfiguration < Seahorse::Client::Plugin
45
45
 
46
- @identifiers = Set.new()
46
+ @identifiers = Set.new
47
47
 
48
48
  # @api private
49
49
  def before_initialize(client_class, options)
@@ -55,17 +55,18 @@ module Aws
55
55
  private
56
56
 
57
57
  def apply_service_defaults(client_class, options)
58
- if defaults = Aws.config[client_class.identifier]
59
- defaults.each do |option_name, default|
60
- options[option_name] = default unless options.key?(option_name)
61
- end
58
+ return unless (defaults = Aws.config[client_class.identifier])
59
+
60
+ defaults.each do |option_name, default|
61
+ options[option_name] = default unless options.key?(option_name)
62
62
  end
63
63
  end
64
64
 
65
- def apply_aws_defaults(client_class, options)
65
+ def apply_aws_defaults(_client_class, options)
66
66
  Aws.config.each do |option_name, default|
67
67
  next if self.class.identifiers.include?(option_name)
68
68
  next if options.key?(option_name)
69
+
69
70
  options[option_name] = default
70
71
  end
71
72
  end
@@ -80,9 +81,7 @@ module Aws
80
81
 
81
82
  # @return [Set<String>]
82
83
  # @api private
83
- def identifiers
84
- @identifiers
85
- end
84
+ attr_reader :identifiers
86
85
 
87
86
  end
88
87
  end
@@ -11,8 +11,8 @@ module Aws
11
11
  CHUNK_SIZE = 1 * 1024 * 1024 # one MB
12
12
 
13
13
  def call(context)
14
- if checksum_required?(context) &&
15
- !context[:checksum_algorithms] && # skip in favor of flexible checksum
14
+ if context.operation.http_checksum_required &&
15
+ !context[:http_checksum][:request_algorithm] && # skip in favor of flexible checksum
16
16
  !context[:s3_express_endpoint] # s3 express endpoints do not support md5
17
17
  body = context.http_request.body
18
18
  context.http_request.headers['Content-Md5'] ||= md5(body)
@@ -22,12 +22,6 @@ module Aws
22
22
 
23
23
  private
24
24
 
25
- def checksum_required?(context)
26
- context.operation.http_checksum_required ||
27
- (context.operation.http_checksum &&
28
- context.operation.http_checksum['requestChecksumRequired'])
29
- end
30
-
31
25
  # @param [File, Tempfile, IO#read, String] value
32
26
  # @return [String<MD5>]
33
27
  def md5(value)
@@ -5,6 +5,8 @@ module Aws
5
5
  module Protocols
6
6
  class ApiGateway < Seahorse::Client::Plugin
7
7
 
8
+ option(:protocol, 'api-gateway')
9
+
8
10
  class ContentTypeHandler < Seahorse::Client::Handler
9
11
  def call(context)
10
12
  body = context.http_request.body
@@ -22,8 +24,8 @@ module Aws
22
24
  handler(Rest::Handler)
23
25
  handler(ContentTypeHandler, priority: 30)
24
26
  handler(Json::ErrorHandler, step: :sign)
25
- end
26
27
 
28
+ end
27
29
  end
28
30
  end
29
31
  end
@@ -1,35 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../../query'
4
-
5
3
  module Aws
6
4
  module Plugins
7
5
  module Protocols
8
6
  class EC2 < Seahorse::Client::Plugin
9
7
 
10
- class Handler < Aws::Query::Handler
11
-
12
- def apply_params(param_list, params, rules)
13
- Aws::Query::EC2ParamBuilder.new(param_list).apply(rules, params)
14
- end
15
-
16
- def parse_xml(context)
17
- if rules = context.operation.output
18
- parser = Xml::Parser.new(rules)
19
- data = parser.parse(xml(context)) do |path, value|
20
- if path.size == 2 && path.last == 'requestId'
21
- context.metadata[:request_id] = value
22
- end
23
- end
24
- data
25
- else
26
- EmptyStructure.new
27
- end
28
- end
29
-
30
- end
8
+ option(:protocol, 'ec2')
31
9
 
32
- handler(Handler)
10
+ handler(Aws::Query::EC2Handler)
33
11
  handler(Xml::ErrorHandler, step: :sign)
34
12
 
35
13
  end
@@ -5,18 +5,17 @@ module Aws
5
5
  module Protocols
6
6
  class JsonRpc < Seahorse::Client::Plugin
7
7
 
8
+ option(:protocol, 'json')
9
+
8
10
  option(:simple_json,
9
11
  default: false,
10
12
  doc_type: 'Boolean',
11
13
  docstring: <<-DOCS)
12
14
  Disables request parameter conversion, validation, and formatting.
13
- Also disable response data type conversions. This option is useful
14
- when you want to ensure the highest level of performance by
15
- avoiding overhead of walking request parameters and response data
16
- structures.
17
-
18
- When `:simple_json` is enabled, the request parameters hash must
19
- be formatted exactly as the DynamoDB API expects.
15
+ Also disables response data type conversions. The request parameters
16
+ hash must be formatted exactly as the API expects.This option is useful
17
+ when you want to ensure the highest level of performance by avoiding
18
+ overhead of walking request parameters and response data structures.
20
19
  DOCS
21
20
 
22
21
  option(:validate_params) { |config| !config.simple_json }
@@ -24,7 +23,6 @@ be formatted exactly as the DynamoDB API expects.
24
23
  option(:convert_params) { |config| !config.simple_json }
25
24
 
26
25
  handler(Json::Handler)
27
-
28
26
  handler(Json::ErrorHandler, step: :sign)
29
27
 
30
28
  end
@@ -1,13 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../../query'
4
-
5
3
  module Aws
6
4
  module Plugins
7
5
  module Protocols
8
6
  class Query < Seahorse::Client::Plugin
7
+
8
+ option(:protocol, 'query')
9
+
9
10
  handler(Aws::Query::Handler)
10
11
  handler(Xml::ErrorHandler, step: :sign)
12
+
11
13
  end
12
14
  end
13
15
  end
@@ -4,13 +4,14 @@ module Aws
4
4
  module Plugins
5
5
  module Protocols
6
6
  class RestJson < Seahorse::Client::Plugin
7
+
8
+ option(:protocol, 'rest-json')
9
+
7
10
  handler(Rest::Handler)
8
- # Rest::Handler will set a default JSON body, so size can be checked
9
- # if this handler is run after serialization.
10
11
  handler(Rest::ContentTypeHandler, priority: 30)
11
12
  handler(Json::ErrorHandler, step: :sign)
12
- end
13
13
 
14
+ end
14
15
  end
15
16
  end
16
17
  end
@@ -4,9 +4,13 @@ module Aws
4
4
  module Plugins
5
5
  module Protocols
6
6
  class RestXml < Seahorse::Client::Plugin
7
+
8
+ option(:protocol, 'rest-xml')
9
+
7
10
  handler(Rest::Handler)
8
- handler(Rest::ContentTypeHandler)
11
+ handler(Rest::ContentTypeHandler, priority: 30)
9
12
  handler(Xml::ErrorHandler, step: :sign)
13
+
10
14
  end
11
15
  end
12
16
  end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ module Plugins
5
+ module Protocols
6
+ class RpcV2 < Seahorse::Client::Plugin
7
+
8
+ option(:protocol, 'smithy-rpc-v2-cbor')
9
+
10
+ handler(Aws::RpcV2::Handler)
11
+ handler(Aws::RpcV2::ContentTypeHandler, priority: 30)
12
+ handler(Aws::RpcV2::ErrorHandler, step: :sign)
13
+
14
+ end
15
+ end
16
+ end
17
+ end
@@ -20,16 +20,31 @@ a default `:region` is searched for in the following locations:
20
20
  * `ENV['AWS_DEFAULT_REGION']`
21
21
  * `~/.aws/credentials`
22
22
  * `~/.aws/config`
23
- DOCS
23
+ DOCS
24
24
  resolve_region(cfg)
25
25
  end
26
26
 
27
+ option(:sigv4a_signing_region_set,
28
+ doc_type: Array,
29
+ rbs_type: 'Array[String]',
30
+ docstring: <<-DOCS) do |cfg|
31
+ A list of regions that should be signed with SigV4a signing. When
32
+ not passed, a default `:sigv4a_signing_region_set` is searched for
33
+ in the following locations:
34
+
35
+ * `Aws.config[:sigv4a_signing_region_set]`
36
+ * `ENV['AWS_SIGV4A_SIGNING_REGION_SET']`
37
+ * `~/.aws/config`
38
+ DOCS
39
+ resolve_sigv4a_signing_region_set(cfg)
40
+ end
41
+
27
42
  option(:use_dualstack_endpoint,
28
43
  doc_type: 'Boolean',
29
44
  docstring: <<-DOCS) do |cfg|
30
45
  When set to `true`, dualstack enabled endpoints (with `.aws` TLD)
31
46
  will be used if available.
32
- DOCS
47
+ DOCS
33
48
  resolve_use_dualstack_endpoint(cfg)
34
49
  end
35
50
 
@@ -39,7 +54,7 @@ will be used if available.
39
54
  When set to `true`, fips compatible endpoints will be used if available.
40
55
  When a `fips` region is used, the region is normalized and this config
41
56
  is set to `true`.
42
- DOCS
57
+ DOCS
43
58
  resolve_use_fips_endpoint(cfg)
44
59
  end
45
60
 
@@ -52,7 +67,7 @@ is set to `true`.
52
67
  docstring: <<-DOCS) do |cfg|
53
68
  Setting to true disables use of endpoint URLs provided via environment
54
69
  variables and the shared configuration file.
55
- DOCS
70
+ DOCS
56
71
  resolve_ignore_configured_endpoint_urls(cfg)
57
72
  end
58
73
 
@@ -60,14 +75,58 @@ variables and the shared configuration file.
60
75
  The client endpoint is normally constructed from the `:region`
61
76
  option. You should only configure an `:endpoint` when connecting
62
77
  to test or custom endpoints. This should be a valid HTTP(S) URI.
63
- DOCS
78
+ DOCS
64
79
  resolve_endpoint(cfg)
65
80
  end
66
81
 
67
82
  def after_initialize(client)
68
- if client.config.region.nil? || client.config.region == ''
69
- raise Errors::MissingRegionError
83
+ region = client.config.region
84
+ raise Errors::MissingRegionError if region.nil? || region == ''
85
+
86
+ # resolve a default endpoint to preserve legacy behavior
87
+ initialize_default_endpoint(client) if client.config.endpoint.nil?
88
+
89
+ region_set = client.config.sigv4a_signing_region_set
90
+ return if region_set.nil?
91
+ raise Errors::InvalidRegionSetError unless region_set.is_a?(Array)
92
+
93
+ region_set = region_set.compact.reject(&:empty?)
94
+ raise Errors::InvalidRegionSetError if region_set.empty?
95
+
96
+ client.config.sigv4a_signing_region_set = region_set
97
+ end
98
+
99
+ private
100
+
101
+ def initialize_default_endpoint(client)
102
+ client_module = Object.const_get(client.class.name.rpartition('::').first)
103
+ param_class = client_module.const_get(:EndpointParameters)
104
+ endpoint_provider = client.config.endpoint_provider
105
+ params = param_class.create(client.config)
106
+ endpoint = endpoint_provider.resolve_endpoint(params)
107
+ client.config.endpoint = endpoint.url
108
+ rescue ArgumentError, NameError
109
+ # fallback to legacy
110
+ client.config.endpoint = resolve_legacy_endpoint(client.config)
111
+ end
112
+
113
+ # set a default endpoint in config using legacy (endpoints.json) resolver
114
+ def resolve_legacy_endpoint(cfg)
115
+ endpoint_prefix = cfg.api.metadata['endpointPrefix']
116
+ if cfg.respond_to?(:sts_regional_endpoints)
117
+ sts_regional = cfg.sts_regional_endpoints
70
118
  end
119
+
120
+ endpoint = Aws::Partitions::EndpointProvider.resolve(
121
+ cfg.region,
122
+ endpoint_prefix,
123
+ sts_regional,
124
+ {
125
+ dualstack: cfg.use_dualstack_endpoint,
126
+ fips: cfg.use_fips_endpoint
127
+ }
128
+ )
129
+ URI(endpoint)
71
130
  end
72
131
 
73
132
  class << self
@@ -81,6 +140,12 @@ to test or custom endpoints. This should be a valid HTTP(S) URI.
81
140
  env_region || cfg_region
82
141
  end
83
142
 
143
+ def resolve_sigv4a_signing_region_set(cfg)
144
+ value = ENV['AWS_SIGV4A_SIGNING_REGION_SET']
145
+ value ||= Aws.shared_config.sigv4a_signing_region_set(profile: cfg.profile)
146
+ value.split(',') if value
147
+ end
148
+
84
149
  def resolve_use_dualstack_endpoint(cfg)
85
150
  value = ENV['AWS_USE_DUALSTACK_ENDPOINT']
86
151
  value ||= Aws.shared_config.use_dualstack_endpoint(
@@ -121,7 +186,8 @@ to test or custom endpoints. This should be a valid HTTP(S) URI.
121
186
  # that a custom endpoint has NOT been configured by the user
122
187
  cfg.override_config(:regional_endpoint, true)
123
188
 
124
- resolve_legacy_endpoint(cfg)
189
+ # a default endpoint is resolved in after_initialize
190
+ nil
125
191
  end
126
192
 
127
193
  # get a custom configured endpoint from ENV or configuration
@@ -176,23 +242,6 @@ to test or custom endpoints. This should be a valid HTTP(S) URI.
176
242
  cfg.override_config(:region, new_region)
177
243
  end
178
244
  end
179
- # set a default endpoint in config using legacy (endpoints.json) resolver
180
- def resolve_legacy_endpoint(cfg)
181
- endpoint_prefix = cfg.api.metadata['endpointPrefix']
182
- if cfg.respond_to?(:sts_regional_endpoints)
183
- sts_regional = cfg.sts_regional_endpoints
184
- end
185
-
186
- Aws::Partitions::EndpointProvider.resolve(
187
- cfg.region,
188
- endpoint_prefix,
189
- sts_regional,
190
- {
191
- dualstack: cfg.use_dualstack_endpoint,
192
- fips: cfg.use_fips_endpoint
193
- }
194
- )
195
- end
196
245
  end
197
246
  end
198
247
  end
@@ -113,7 +113,6 @@ Specifies which retry algorithm to use. Values are:
113
113
  functionality of `standard` mode along with automatic client side
114
114
  throttling. This is a provisional mode that may change behavior
115
115
  in the future.
116
-
117
116
  DOCS
118
117
  resolve_retry_mode(cfg)
119
118
  end
@@ -13,8 +13,7 @@ module Aws
13
13
  option(:sigv4_region)
14
14
  option(:unsigned_operations, default: [])
15
15
 
16
- supported_auth_types = %w[sigv4 bearer sigv4-s3express none]
17
- supported_auth_types += ['sigv4a'] if Aws::Sigv4::Signer.use_crt?
16
+ supported_auth_types = %w[sigv4 bearer sigv4-s3express sigv4a none]
18
17
  SUPPORTED_AUTH_TYPES = supported_auth_types.freeze
19
18
 
20
19
  def add_handlers(handlers, cfg)
@@ -42,6 +41,7 @@ module Aws
42
41
  class Handler < Seahorse::Client::Handler
43
42
  def call(context)
44
43
  # Skip signing if using sigv2 signing from s3_signer in S3
44
+ credentials = nil
45
45
  unless v2_signing?(context.config)
46
46
  signer = Sign.signer_for(
47
47
  context[:auth_scheme],
@@ -49,13 +49,20 @@ module Aws
49
49
  context[:sigv4_region],
50
50
  context[:sigv4_credentials]
51
51
  )
52
+ credentials = signer.credentials if signer.is_a?(SignatureV4)
52
53
  signer.sign(context)
53
54
  end
54
- @handler.call(context)
55
+ with_metrics(credentials) { @handler.call(context) }
55
56
  end
56
57
 
57
58
  private
58
59
 
60
+ def with_metrics(credentials, &block)
61
+ return block.call unless credentials&.respond_to?(:metrics)
62
+
63
+ Aws::Plugins::UserAgent.metric(*credentials.metrics, &block)
64
+ end
65
+
59
66
  def v2_signing?(config)
60
67
  # 's3' is legacy signing, 'v4' is default
61
68
  config.respond_to?(:signature_version) &&
@@ -93,6 +100,8 @@ module Aws
93
100
 
94
101
  # @api private
95
102
  class SignatureV4
103
+ attr_reader :signer
104
+
96
105
  def initialize(auth_scheme, config, sigv4_overrides = {})
97
106
  scheme_name = auth_scheme['name']
98
107
 
@@ -102,19 +111,19 @@ module Aws
102
111
  end
103
112
 
104
113
  region = if scheme_name == 'sigv4a'
105
- auth_scheme['signingRegionSet'].first
114
+ auth_scheme['signingRegionSet'].join(',')
106
115
  else
107
116
  auth_scheme['signingRegion']
108
117
  end
109
118
  begin
110
- @signer = Aws::Sigv4::Signer.new(
119
+ @signer = config.sigv4_signer || Aws::Sigv4::Signer.new(
111
120
  service: config.sigv4_name || auth_scheme['signingName'],
112
121
  region: sigv4_overrides[:region] || config.sigv4_region || region,
113
122
  credentials_provider: sigv4_overrides[:credentials] || config.credentials,
114
123
  signing_algorithm: scheme_name.to_sym,
115
124
  uri_escape_path: !!!auth_scheme['disableDoubleEncoding'],
116
125
  normalize_path: !!!auth_scheme['disableNormalizePath'],
117
- unsigned_headers: %w[content-length user-agent x-amzn-trace-id]
126
+ unsigned_headers: %w[content-length user-agent x-amzn-trace-id expect transfer-encoding connection]
118
127
  )
119
128
  rescue Aws::Sigv4::Errors::MissingCredentialsError
120
129
  raise Aws::Errors::MissingCredentialsError
@@ -156,20 +165,27 @@ module Aws
156
165
  @signer.sign_event(*args)
157
166
  end
158
167
 
168
+ def credentials
169
+ @signer.credentials_provider
170
+ end
171
+
159
172
  private
160
173
 
161
174
  def apply_authtype(context, req)
162
- # only used for eventstreaming at input
175
+ # only used for event streaming at input
163
176
  if context[:input_event_emitter]
164
177
  req.headers['X-Amz-Content-Sha256'] = 'STREAMING-AWS4-HMAC-SHA256-EVENTS'
165
- else
166
- if context.operation['authtype'].eql?('v4-unsigned-body') &&
167
- req.endpoint.scheme.eql?('https')
168
- req.headers['X-Amz-Content-Sha256'] ||= 'UNSIGNED-PAYLOAD'
169
- end
178
+ elsif unsigned_payload?(context, req)
179
+ req.headers['X-Amz-Content-Sha256'] ||= 'UNSIGNED-PAYLOAD'
170
180
  end
171
181
  end
172
182
 
183
+ def unsigned_payload?(context, req)
184
+ (context.operation['unsignedPayload'] ||
185
+ context.operation['authtype'] == 'v4-unsigned-body') &&
186
+ req.endpoint.scheme == 'https'
187
+ end
188
+
173
189
  def reset_signature(req)
174
190
  # in case this request is being re-signed
175
191
  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]