aws-sdk-core 3.131.1 → 3.188.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 (100) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +459 -0
  3. data/VERSION +1 -1
  4. data/lib/aws-defaults/default_configuration.rb +4 -4
  5. data/lib/aws-sdk-core/arn.rb +13 -0
  6. data/lib/aws-sdk-core/binary/encode_handler.rb +12 -1
  7. data/lib/aws-sdk-core/credential_provider.rb +3 -0
  8. data/lib/aws-sdk-core/credential_provider_chain.rb +8 -5
  9. data/lib/aws-sdk-core/ecs_credentials.rb +177 -53
  10. data/lib/aws-sdk-core/endpoints/condition.rb +41 -0
  11. data/lib/aws-sdk-core/endpoints/endpoint.rb +17 -0
  12. data/lib/aws-sdk-core/endpoints/endpoint_rule.rb +75 -0
  13. data/lib/aws-sdk-core/endpoints/error_rule.rb +42 -0
  14. data/lib/aws-sdk-core/endpoints/function.rb +80 -0
  15. data/lib/aws-sdk-core/endpoints/matchers.rb +131 -0
  16. data/lib/aws-sdk-core/endpoints/reference.rb +31 -0
  17. data/lib/aws-sdk-core/endpoints/rule.rb +25 -0
  18. data/lib/aws-sdk-core/endpoints/rule_set.rb +52 -0
  19. data/lib/aws-sdk-core/endpoints/rules_provider.rb +37 -0
  20. data/lib/aws-sdk-core/endpoints/templater.rb +58 -0
  21. data/lib/aws-sdk-core/endpoints/tree_rule.rb +45 -0
  22. data/lib/aws-sdk-core/endpoints/url.rb +60 -0
  23. data/lib/aws-sdk-core/endpoints.rb +78 -0
  24. data/lib/aws-sdk-core/errors.rb +14 -1
  25. data/lib/aws-sdk-core/ini_parser.rb +7 -0
  26. data/lib/aws-sdk-core/instance_profile_credentials.rb +52 -30
  27. data/lib/aws-sdk-core/json/error_handler.rb +20 -1
  28. data/lib/aws-sdk-core/json/handler.rb +8 -1
  29. data/lib/aws-sdk-core/json/parser.rb +27 -2
  30. data/lib/aws-sdk-core/log/formatter.rb +6 -0
  31. data/lib/aws-sdk-core/pageable_response.rb +10 -1
  32. data/lib/aws-sdk-core/param_validator.rb +2 -2
  33. data/lib/aws-sdk-core/plugins/bearer_authorization.rb +67 -0
  34. data/lib/aws-sdk-core/plugins/checksum_algorithm.rb +1 -1
  35. data/lib/aws-sdk-core/plugins/credentials_configuration.rb +24 -0
  36. data/lib/aws-sdk-core/plugins/endpoint_discovery.rb +6 -2
  37. data/lib/aws-sdk-core/plugins/jsonvalue_converter.rb +34 -6
  38. data/lib/aws-sdk-core/plugins/recursion_detection.rb +14 -3
  39. data/lib/aws-sdk-core/plugins/regional_endpoint.rb +111 -30
  40. data/lib/aws-sdk-core/plugins/request_compression.rb +217 -0
  41. data/lib/aws-sdk-core/plugins/retries/error_inspector.rb +2 -1
  42. data/lib/aws-sdk-core/plugins/sign.rb +201 -0
  43. data/lib/aws-sdk-core/plugins/signature_v2.rb +1 -0
  44. data/lib/aws-sdk-core/plugins/signature_v4.rb +13 -7
  45. data/lib/aws-sdk-core/plugins/user_agent.rb +117 -14
  46. data/lib/aws-sdk-core/refreshing_credentials.rb +0 -6
  47. data/lib/aws-sdk-core/refreshing_token.rb +71 -0
  48. data/lib/aws-sdk-core/rest/handler.rb +1 -1
  49. data/lib/aws-sdk-core/rest/request/headers.rb +2 -6
  50. data/lib/aws-sdk-core/rest/request/querystring_builder.rb +43 -29
  51. data/lib/aws-sdk-core/shared_config.rb +106 -6
  52. data/lib/aws-sdk-core/sso_credentials.rb +80 -45
  53. data/lib/aws-sdk-core/sso_token_provider.rb +135 -0
  54. data/lib/aws-sdk-core/static_token_provider.rb +14 -0
  55. data/lib/aws-sdk-core/structure.rb +6 -4
  56. data/lib/aws-sdk-core/stubbing/stub_data.rb +11 -0
  57. data/lib/aws-sdk-core/token.rb +31 -0
  58. data/lib/aws-sdk-core/token_provider.rb +15 -0
  59. data/lib/aws-sdk-core/token_provider_chain.rb +51 -0
  60. data/lib/aws-sdk-core/waiters/poller.rb +3 -1
  61. data/lib/aws-sdk-core/xml/error_handler.rb +7 -0
  62. data/lib/aws-sdk-core/xml/parser/engines/oga.rb +2 -0
  63. data/lib/aws-sdk-core.rb +14 -0
  64. data/lib/aws-sdk-sso/client.rb +71 -11
  65. data/lib/aws-sdk-sso/endpoint_parameters.rb +66 -0
  66. data/lib/aws-sdk-sso/endpoint_provider.rb +57 -0
  67. data/lib/aws-sdk-sso/endpoints.rb +72 -0
  68. data/lib/aws-sdk-sso/plugins/endpoints.rb +76 -0
  69. data/lib/aws-sdk-sso/types.rb +8 -43
  70. data/lib/aws-sdk-sso.rb +5 -1
  71. data/lib/aws-sdk-ssooidc/client.rb +935 -0
  72. data/lib/aws-sdk-ssooidc/client_api.rb +271 -0
  73. data/lib/aws-sdk-ssooidc/customizations.rb +1 -0
  74. data/lib/aws-sdk-ssooidc/endpoint_parameters.rb +66 -0
  75. data/lib/aws-sdk-ssooidc/endpoint_provider.rb +57 -0
  76. data/lib/aws-sdk-ssooidc/endpoints.rb +72 -0
  77. data/lib/aws-sdk-ssooidc/errors.rb +321 -0
  78. data/lib/aws-sdk-ssooidc/plugins/endpoints.rb +76 -0
  79. data/lib/aws-sdk-ssooidc/resource.rb +26 -0
  80. data/lib/aws-sdk-ssooidc/types.rb +755 -0
  81. data/lib/aws-sdk-ssooidc.rb +59 -0
  82. data/lib/aws-sdk-sts/client.rb +298 -245
  83. data/lib/aws-sdk-sts/client_api.rb +12 -1
  84. data/lib/aws-sdk-sts/endpoint_parameters.rb +78 -0
  85. data/lib/aws-sdk-sts/endpoint_provider.rb +112 -0
  86. data/lib/aws-sdk-sts/endpoints.rb +136 -0
  87. data/lib/aws-sdk-sts/plugins/endpoints.rb +84 -0
  88. data/lib/aws-sdk-sts/presigner.rb +14 -16
  89. data/lib/aws-sdk-sts/types.rb +128 -197
  90. data/lib/aws-sdk-sts.rb +5 -1
  91. data/lib/seahorse/client/async_base.rb +0 -1
  92. data/lib/seahorse/client/configuration.rb +1 -5
  93. data/lib/seahorse/client/h2/connection.rb +12 -11
  94. data/lib/seahorse/client/net_http/patches.rb +1 -4
  95. data/lib/seahorse/client/plugins/h2.rb +3 -3
  96. data/lib/seahorse/client/plugins/request_callback.rb +40 -9
  97. data/lib/seahorse/client/response.rb +6 -0
  98. data/lib/seahorse/model/operation.rb +3 -0
  99. data/lib/seahorse/util.rb +4 -0
  100. metadata +49 -7
@@ -10,8 +10,9 @@ module Aws
10
10
  include Seahorse::Model::Shapes
11
11
 
12
12
  # @param [Seahorse::Model::ShapeRef] rules
13
- def initialize(rules)
13
+ def initialize(rules, query_compatible: false)
14
14
  @rules = rules
15
+ @query_compatible = query_compatible
15
16
  end
16
17
 
17
18
  # @param [String<JSON>] json
@@ -28,10 +29,26 @@ module Aws
28
29
  member_name, member_ref = shape.member_by_location_name(key)
29
30
  if member_ref
30
31
  target[member_name] = parse_ref(member_ref, value)
31
- elsif shape.union
32
+ elsif shape.union && key != '__type'
32
33
  target[:unknown] = { 'name' => key, 'value' => value }
33
34
  end
34
35
  end
36
+ # In services that were previously Query/XML, members that were
37
+ # "flattened" defaulted to empty lists. In JSON, these values are nil,
38
+ # which is backwards incompatible. To preserve backwards compatibility,
39
+ # we set a default value of [] for these members.
40
+ if @query_compatible
41
+ ref.shape.members.each do |member_name, member_target|
42
+ next unless target[member_name].nil?
43
+
44
+ if flattened_list?(member_target.shape)
45
+ target[member_name] = []
46
+ elsif flattened_map?(member_target.shape)
47
+ target[member_name] = {}
48
+ end
49
+ end
50
+ end
51
+
35
52
  if shape.union
36
53
  # convert to subclass
37
54
  member_subclass = shape.member_subclass(target.member).new
@@ -79,6 +96,14 @@ module Aws
79
96
  value.is_a?(Numeric) ? Time.at(value) : Time.parse(value)
80
97
  end
81
98
 
99
+ def flattened_list?(shape)
100
+ shape.is_a?(ListShape) && shape.flattened
101
+ end
102
+
103
+ def flattened_map?(shape)
104
+ shape.is_a?(MapShape) && shape.flattened
105
+ end
106
+
82
107
  end
83
108
  end
84
109
  end
@@ -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
@@ -146,6 +146,13 @@ module Aws
146
146
  data.to_h
147
147
  end
148
148
 
149
+ def as_json(_options = {})
150
+ data.to_h(data, as_json: true)
151
+ end
152
+
153
+ def to_json(options = {})
154
+ as_json.to_json(options)
155
+ end
149
156
  end
150
157
 
151
158
  # The actual decorator module implementation. It is in a distinct module
@@ -194,7 +201,9 @@ module Aws
194
201
  def next_response(params)
195
202
  params = next_page_params(params)
196
203
  request = context.client.build_request(context.operation_name, params)
197
- request.send_request
204
+ Aws::Plugins::UserAgent.feature('paginator') do
205
+ request.send_request
206
+ end
198
207
  end
199
208
 
200
209
  def next_page_params(params)
@@ -6,7 +6,7 @@ module Aws
6
6
 
7
7
  include Seahorse::Model::Shapes
8
8
 
9
- EXPECTED_GOT = "expected %s to be %s, got value %s (class: %s) instead."
9
+ EXPECTED_GOT = 'expected %s to be %s, got class %s instead.'
10
10
 
11
11
  # @param [Seahorse::Model::Shapes::ShapeRef] rules
12
12
  # @param [Hash] params
@@ -230,7 +230,7 @@ module Aws
230
230
  end
231
231
 
232
232
  def expected_got(context, expected, got)
233
- EXPECTED_GOT % [context, expected, got.inspect, got.class.name]
233
+ EXPECTED_GOT % [context, expected, got.class.name]
234
234
  end
235
235
 
236
236
  end
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ # @api private
5
+ module Plugins
6
+ # @api private
7
+ class BearerAuthorization < Seahorse::Client::Plugin
8
+
9
+ option(:token_provider,
10
+ required: false,
11
+ doc_type: 'Aws::TokenProvider',
12
+ docstring: <<-DOCS
13
+ A Bearer Token Provider. This can be an instance of any one of the
14
+ following classes:
15
+
16
+ * `Aws::StaticTokenProvider` - Used for configuring static, non-refreshing
17
+ tokens.
18
+
19
+ * `Aws::SSOTokenProvider` - Used for loading tokens from AWS SSO using an
20
+ access token generated from `aws login`.
21
+
22
+ When `:token_provider` is not configured directly, the `Aws::TokenProviderChain`
23
+ will be used to search for tokens configured for your profile in shared configuration files.
24
+ DOCS
25
+ ) do |config|
26
+ if config.stub_responses
27
+ StaticTokenProvider.new('token')
28
+ else
29
+ TokenProviderChain.new(config).resolve
30
+ end
31
+ end
32
+
33
+
34
+ def add_handlers(handlers, cfg)
35
+ bearer_operations =
36
+ if cfg.api.metadata['signatureVersion'] == 'bearer'
37
+ # select operations where authtype is either not set or is bearer
38
+ cfg.api.operation_names.select do |o|
39
+ !cfg.api.operation(o)['authtype'] || cfg.api.operation(o)['authtype'] == 'bearer'
40
+ end
41
+ else # service is not bearer auth
42
+ # select only operations where authtype is explicitly bearer
43
+ cfg.api.operation_names.select do |o|
44
+ cfg.api.operation(o)['authtype'] == 'bearer'
45
+ end
46
+ end
47
+ handlers.add(Handler, step: :sign, operations: bearer_operations)
48
+ end
49
+
50
+ class Handler < Seahorse::Client::Handler
51
+ def call(context)
52
+ if context.http_request.endpoint.scheme != 'https'
53
+ raise ArgumentError, 'Unable to use bearer authorization on non https endpoint.'
54
+ end
55
+
56
+ token_provider = context.config.token_provider
57
+ if token_provider && token_provider.set?
58
+ context.http_request.headers['Authorization'] = "Bearer #{token_provider.token.token}"
59
+ else
60
+ raise Errors::MissingBearerTokenError
61
+ end
62
+ @handler.call(context)
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
@@ -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)
@@ -76,6 +76,30 @@ locations will be searched for credentials:
76
76
 
77
77
  option(:instance_profile_credentials_timeout, 1)
78
78
 
79
+ option(:token_provider,
80
+ required: false,
81
+ doc_type: 'Aws::TokenProvider',
82
+ docstring: <<-DOCS
83
+ A Bearer Token Provider. This can be an instance of any one of the
84
+ following classes:
85
+
86
+ * `Aws::StaticTokenProvider` - Used for configuring static, non-refreshing
87
+ tokens.
88
+
89
+ * `Aws::SSOTokenProvider` - Used for loading tokens from AWS SSO using an
90
+ access token generated from `aws login`.
91
+
92
+ When `:token_provider` is not configured directly, the `Aws::TokenProviderChain`
93
+ will be used to search for tokens configured for your profile in shared configuration files.
94
+ DOCS
95
+ ) do |config|
96
+ if config.stub_responses
97
+ StaticTokenProvider.new('token')
98
+ else
99
+ TokenProviderChain.new(config).resolve
100
+ end
101
+ end
102
+
79
103
  end
80
104
  end
81
105
  end
@@ -72,7 +72,11 @@ the background every 60 secs (default). Defaults to `false`.
72
72
  context,
73
73
  Aws::Util.str_2_bool(discovery_cfg["required"])
74
74
  )
75
- context.http_request.endpoint = _valid_uri(endpoint.address) if endpoint
75
+ if endpoint
76
+ context.http_request.endpoint = _valid_uri(endpoint.address)
77
+ # Skips dynamic endpoint usage, use this endpoint instead
78
+ context[:discovered_endpoint] = true
79
+ end
76
80
  if endpoint || context.config.endpoint_discovery
77
81
  _apply_endpoint_discovery_user_agent(context)
78
82
  end
@@ -100,7 +104,7 @@ the background every 60 secs (default). Defaults to `false`.
100
104
  end
101
105
 
102
106
  def _discover_endpoint(ctx, required)
103
- cache = ctx.config.endpoint_cache
107
+ cache = ctx.config.endpoint_cache
104
108
  key = cache.extract_key(ctx)
105
109
 
106
110
  if required
@@ -11,15 +11,43 @@ module Aws
11
11
 
12
12
  def call(context)
13
13
  context.operation.input.shape.members.each do |m, ref|
14
- if ref['jsonvalue']
15
- param_value = context.params[m]
16
- unless param_value.respond_to?(:to_json)
17
- raise ArgumentError, "The value of params[#{m}] is not JSON serializable."
14
+ convert_jsonvalue(m, ref, context.params, 'params')
15
+ end
16
+ @handler.call(context)
17
+ end
18
+
19
+ def convert_jsonvalue(m, ref, params, context)
20
+ return if params.nil? || !params.key?(m)
21
+
22
+ if ref['jsonvalue']
23
+ params[m] = serialize_jsonvalue(params[m], "#{context}[#{m}]")
24
+ else
25
+ case ref.shape
26
+ when Seahorse::Model::Shapes::StructureShape
27
+ ref.shape.members.each do |member_m, ref|
28
+ convert_jsonvalue(member_m, ref, params[m], "#{context}[#{m}]")
29
+ end
30
+ when Seahorse::Model::Shapes::ListShape
31
+ if ref.shape.member['jsonvalue']
32
+ params[m] = params[m].each_with_index.map do |v, i|
33
+ serialize_jsonvalue(v, "#{context}[#{m}][#{i}]")
34
+ end
35
+ end
36
+ when Seahorse::Model::Shapes::MapShape
37
+ if ref.shape.value['jsonvalue']
38
+ params[m].each do |k, v|
39
+ params[m][k] = serialize_jsonvalue(v, "#{context}[#{m}][#{k}]")
40
+ end
18
41
  end
19
- context.params[m] = param_value.to_json
20
42
  end
21
43
  end
22
- @handler.call(context)
44
+ end
45
+
46
+ def serialize_jsonvalue(v, context)
47
+ unless v.respond_to?(:to_json)
48
+ raise ArgumentError, "The value of #{context} is not JSON serializable."
49
+ end
50
+ v.to_json
23
51
  end
24
52
 
25
53
  end
@@ -9,14 +9,25 @@ module Aws
9
9
  class Handler < Seahorse::Client::Handler
10
10
  def call(context)
11
11
 
12
- unless context.http_request.headers.key?('x-amz-trace-id')
12
+ unless context.http_request.headers.key?('x-amzn-trace-id')
13
13
  if ENV['AWS_LAMBDA_FUNCTION_NAME'] &&
14
- (trace_id = ENV['_X_AMZ_TRACE_ID'])
15
- context.http_request.headers['x-amz-trace-id'] = trace_id
14
+ (trace_id = validate_header(ENV['_X_AMZN_TRACE_ID']))
15
+ context.http_request.headers['x-amzn-trace-id'] = trace_id
16
16
  end
17
17
  end
18
18
  @handler.call(context)
19
19
  end
20
+
21
+ private
22
+ def validate_header(header_value)
23
+ return unless header_value
24
+
25
+ if (header_value.chars & (0..31).map(&:chr)).any?
26
+ raise ArgumentError, 'Invalid _X_AMZN_TRACE_ID value: '\
27
+ 'contains ASCII control characters'
28
+ end
29
+ header_value
30
+ end
20
31
  end
21
32
 
22
33
  # should be at the end of build so that
@@ -43,43 +43,25 @@ is set to `true`.
43
43
  resolve_use_fips_endpoint(cfg)
44
44
  end
45
45
 
46
+ # This option signals whether :endpoint was provided or not.
47
+ # Legacy endpoints must continue to be generated at client time.
46
48
  option(:regional_endpoint, false)
47
49
 
50
+ option(:ignore_configured_endpoint_urls,
51
+ doc_type: 'Boolean',
52
+ docstring: <<-DOCS) do |cfg|
53
+ Setting to true disables use of endpoint URLs provided via environment
54
+ variables and the shared configuration file.
55
+ DOCS
56
+ resolve_ignore_configured_endpoint_urls(cfg)
57
+ end
58
+
48
59
  option(:endpoint, doc_type: String, docstring: <<-DOCS) do |cfg|
49
60
  The client endpoint is normally constructed from the `:region`
50
61
  option. You should only configure an `:endpoint` when connecting
51
62
  to test or custom endpoints. This should be a valid HTTP(S) URI.
52
63
  DOCS
53
- endpoint_prefix = cfg.api.metadata['endpointPrefix']
54
- if cfg.region && endpoint_prefix
55
- if cfg.respond_to?(:sts_regional_endpoints)
56
- sts_regional = cfg.sts_regional_endpoints
57
- end
58
-
59
- # check region is a valid RFC host label
60
- unless Seahorse::Util.host_label?(cfg.region)
61
- raise Errors::InvalidRegionError
62
- end
63
-
64
- region = cfg.region
65
- new_region = region.gsub('fips-', '').gsub('-fips', '')
66
- if region != new_region
67
- warn("Legacy region #{region} was transformed to #{new_region}."\
68
- '`use_fips_endpoint` config was set to true.')
69
- cfg.override_config(:use_fips_endpoint, true)
70
- cfg.override_config(:region, new_region)
71
- end
72
-
73
- Aws::Partitions::EndpointProvider.resolve(
74
- cfg.region,
75
- endpoint_prefix,
76
- sts_regional,
77
- {
78
- dualstack: cfg.use_dualstack_endpoint,
79
- fips: cfg.use_fips_endpoint
80
- }
81
- )
82
- end
64
+ resolve_endpoint(cfg)
83
65
  end
84
66
 
85
67
  def after_initialize(client)
@@ -112,6 +94,105 @@ to test or custom endpoints. This should be a valid HTTP(S) URI.
112
94
  value ||= Aws.shared_config.use_fips_endpoint(profile: cfg.profile)
113
95
  Aws::Util.str_2_bool(value) || false
114
96
  end
97
+
98
+ def resolve_ignore_configured_endpoint_urls(cfg)
99
+ value = ENV['AWS_IGNORE_CONFIGURED_ENDPOINT_URLS']
100
+ value ||= Aws.shared_config.ignore_configured_endpoint_urls(profile: cfg.profile)
101
+ Aws::Util.str_2_bool(value&.downcase) || false
102
+ end
103
+
104
+ # NOTE: with Endpoints 2.0, some of this logic is deprecated
105
+ # but because new old service gems may depend on new core versions
106
+ # we must preserve that behavior.
107
+ # Additional behavior controls the setting of the custom SDK::Endpoint
108
+ # parameter.
109
+ # When the `regional_endpoint` config is set to true - this indicates to
110
+ # Endpoints2.0 that a custom endpoint has NOT been configured by the user.
111
+ def resolve_endpoint(cfg)
112
+ endpoint = resolve_custom_config_endpoint(cfg)
113
+ endpoint_prefix = cfg.api.metadata['endpointPrefix']
114
+
115
+ return endpoint unless endpoint.nil? && cfg.region && endpoint_prefix
116
+
117
+ validate_region!(cfg.region)
118
+ handle_legacy_pseudo_regions(cfg)
119
+
120
+ # set regional_endpoint flag - this indicates to Endpoints 2.0
121
+ # that a custom endpoint has NOT been configured by the user
122
+ cfg.override_config(:regional_endpoint, true)
123
+
124
+ resolve_legacy_endpoint(cfg)
125
+ end
126
+
127
+ # get a custom configured endpoint from ENV or configuration
128
+ def resolve_custom_config_endpoint(cfg)
129
+ return if cfg.ignore_configured_endpoint_urls
130
+
131
+
132
+ env_service_endpoint(cfg) || env_global_endpoint(cfg) || shared_config_endpoint(cfg)
133
+ end
134
+
135
+ def env_service_endpoint(cfg)
136
+ service_id = cfg.api.metadata['serviceId'] || cfg.api.metadata['endpointPrefix']
137
+ env_service_id = service_id.gsub(" ", "_").upcase
138
+ return unless endpoint = ENV["AWS_ENDPOINT_URL_#{env_service_id}"]
139
+
140
+ cfg.logger&.debug(
141
+ "Endpoint configured from ENV['AWS_ENDPOINT_URL_#{env_service_id}']: #{endpoint}\n")
142
+ endpoint
143
+ end
144
+
145
+ def env_global_endpoint(cfg)
146
+ return unless endpoint = ENV['AWS_ENDPOINT_URL']
147
+
148
+ cfg.logger&.debug(
149
+ "Endpoint configured from ENV['AWS_ENDPOINT_URL']: #{endpoint}\n")
150
+ endpoint
151
+ end
152
+
153
+ def shared_config_endpoint(cfg)
154
+ service_id = cfg.api.metadata['serviceId'] || cfg.api.metadata['endpointPrefix']
155
+ return unless endpoint = Aws.shared_config.configured_endpoint(profile: cfg.profile, service_id: service_id)
156
+
157
+ cfg.logger&.debug(
158
+ "Endpoint configured from shared config(profile: #{cfg.profile}): #{endpoint}\n")
159
+ endpoint
160
+ end
161
+
162
+ # check region is a valid RFC host label
163
+ def validate_region!(region)
164
+ unless Seahorse::Util.host_label?(region)
165
+ raise Errors::InvalidRegionError
166
+ end
167
+ end
168
+
169
+ def handle_legacy_pseudo_regions(cfg)
170
+ region = cfg.region
171
+ new_region = region.gsub('fips-', '').gsub('-fips', '')
172
+ if region != new_region
173
+ warn("Legacy region #{region} was transformed to #{new_region}."\
174
+ '`use_fips_endpoint` config was set to true.')
175
+ cfg.override_config(:use_fips_endpoint, true)
176
+ cfg.override_config(:region, new_region)
177
+ end
178
+ 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
115
196
  end
116
197
  end
117
198
  end