aws-sdk-core 3.201.2 → 3.226.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +324 -0
- data/VERSION +1 -1
- data/lib/aws-defaults/default_configuration.rb +1 -2
- data/lib/aws-defaults.rb +4 -1
- data/lib/aws-sdk-core/arn.rb +1 -3
- data/lib/aws-sdk-core/assume_role_credentials.rb +13 -5
- data/lib/aws-sdk-core/assume_role_web_identity_credentials.rb +14 -7
- data/lib/aws-sdk-core/cbor/decoder.rb +0 -2
- data/lib/aws-sdk-core/cbor/encoder.rb +2 -2
- data/lib/aws-sdk-core/cbor.rb +3 -56
- data/lib/aws-sdk-core/client_side_monitoring.rb +9 -0
- data/lib/aws-sdk-core/client_stubs.rb +29 -55
- data/lib/aws-sdk-core/credential_provider.rb +4 -0
- data/lib/aws-sdk-core/credential_provider_chain.rb +35 -8
- data/lib/aws-sdk-core/credentials.rb +19 -6
- data/lib/aws-sdk-core/ecs_credentials.rb +1 -0
- data/lib/aws-sdk-core/endpoints/endpoint.rb +3 -1
- data/lib/aws-sdk-core/endpoints/matchers.rb +3 -9
- data/lib/aws-sdk-core/endpoints.rb +13 -3
- data/lib/aws-sdk-core/error_handler.rb +5 -0
- data/lib/aws-sdk-core/errors.rb +2 -2
- data/lib/aws-sdk-core/event_emitter.rb +1 -1
- data/lib/aws-sdk-core/instance_profile_credentials.rb +1 -0
- data/lib/aws-sdk-core/json/error_handler.rb +14 -3
- data/lib/aws-sdk-core/json/handler.rb +1 -0
- data/lib/aws-sdk-core/log/param_formatter.rb +7 -3
- data/lib/aws-sdk-core/log.rb +10 -0
- data/lib/aws-sdk-core/plugins/checksum_algorithm.rb +332 -170
- data/lib/aws-sdk-core/plugins/client_metrics_plugin.rb +0 -1
- data/lib/aws-sdk-core/plugins/credentials_configuration.rb +7 -3
- data/lib/aws-sdk-core/plugins/endpoint_pattern.rb +40 -32
- data/lib/aws-sdk-core/plugins/http_checksum.rb +2 -8
- data/lib/aws-sdk-core/plugins/regional_endpoint.rb +44 -24
- data/lib/aws-sdk-core/plugins/sign.rb +18 -5
- data/lib/aws-sdk-core/plugins/stub_responses.rb +52 -9
- data/lib/aws-sdk-core/plugins/telemetry.rb +75 -0
- data/lib/aws-sdk-core/plugins/user_agent.rb +48 -9
- data/lib/aws-sdk-core/plugins.rb +39 -0
- data/lib/aws-sdk-core/process_credentials.rb +3 -2
- data/lib/aws-sdk-core/resources.rb +8 -0
- data/lib/aws-sdk-core/rest/request/headers.rb +3 -3
- data/lib/aws-sdk-core/rpc_v2/builder.rb +1 -1
- data/lib/aws-sdk-core/{cbor → rpc_v2}/cbor_engine.rb +4 -5
- data/lib/aws-sdk-core/rpc_v2/content_type_handler.rb +3 -1
- data/lib/aws-sdk-core/rpc_v2/error_handler.rb +27 -16
- data/lib/aws-sdk-core/rpc_v2/handler.rb +7 -2
- data/lib/aws-sdk-core/rpc_v2/parser.rb +9 -1
- data/lib/aws-sdk-core/rpc_v2.rb +65 -2
- data/lib/aws-sdk-core/shared_config.rb +77 -22
- data/lib/aws-sdk-core/shared_credentials.rb +1 -7
- data/lib/aws-sdk-core/sso_credentials.rb +4 -1
- data/lib/aws-sdk-core/stubbing/protocols/ec2.rb +12 -11
- data/lib/aws-sdk-core/stubbing/protocols/json.rb +11 -10
- data/lib/aws-sdk-core/stubbing/protocols/query.rb +7 -6
- data/lib/aws-sdk-core/stubbing/protocols/rest.rb +2 -1
- data/lib/aws-sdk-core/stubbing/protocols/rest_json.rb +9 -8
- data/lib/aws-sdk-core/stubbing/protocols/rest_xml.rb +6 -5
- data/lib/aws-sdk-core/stubbing/protocols/rpc_v2.rb +13 -15
- data/lib/aws-sdk-core/stubbing.rb +22 -0
- data/lib/aws-sdk-core/telemetry/base.rb +177 -0
- data/lib/aws-sdk-core/telemetry/no_op.rb +70 -0
- data/lib/aws-sdk-core/telemetry/otel.rb +235 -0
- data/lib/aws-sdk-core/telemetry/span_kind.rb +22 -0
- data/lib/aws-sdk-core/telemetry/span_status.rb +59 -0
- data/lib/aws-sdk-core/telemetry.rb +78 -0
- data/lib/aws-sdk-core/util.rb +2 -1
- data/lib/aws-sdk-core/waiters/poller.rb +9 -4
- data/lib/aws-sdk-core/xml/error_handler.rb +3 -1
- data/lib/aws-sdk-core.rb +82 -112
- data/lib/aws-sdk-sso/client.rb +86 -37
- data/lib/aws-sdk-sso/client_api.rb +1 -0
- data/lib/aws-sdk-sso/endpoint_parameters.rb +9 -6
- data/lib/aws-sdk-sso/endpoint_provider.rb +14 -18
- data/lib/aws-sdk-sso/endpoints.rb +2 -54
- data/lib/aws-sdk-sso/plugins/endpoints.rb +19 -20
- data/lib/aws-sdk-sso/types.rb +1 -0
- data/lib/aws-sdk-sso.rb +15 -11
- data/lib/aws-sdk-ssooidc/client.rb +123 -57
- data/lib/aws-sdk-ssooidc/client_api.rb +7 -0
- data/lib/aws-sdk-ssooidc/endpoint_parameters.rb +9 -6
- data/lib/aws-sdk-ssooidc/endpoint_provider.rb +14 -18
- data/lib/aws-sdk-ssooidc/endpoints.rb +2 -54
- data/lib/aws-sdk-ssooidc/plugins/endpoints.rb +19 -20
- data/lib/aws-sdk-ssooidc/types.rb +49 -16
- data/lib/aws-sdk-ssooidc.rb +15 -11
- data/lib/aws-sdk-sts/client.rb +294 -89
- data/lib/aws-sdk-sts/client_api.rb +34 -8
- data/lib/aws-sdk-sts/customizations.rb +5 -1
- data/lib/aws-sdk-sts/endpoint_parameters.rb +10 -9
- data/lib/aws-sdk-sts/endpoint_provider.rb +50 -55
- data/lib/aws-sdk-sts/endpoints.rb +2 -118
- data/lib/aws-sdk-sts/errors.rb +15 -0
- data/lib/aws-sdk-sts/plugins/endpoints.rb +19 -28
- data/lib/aws-sdk-sts/types.rb +171 -28
- data/lib/aws-sdk-sts.rb +15 -11
- data/lib/seahorse/client/async_base.rb +4 -5
- data/lib/seahorse/client/base.rb +0 -14
- data/lib/seahorse/client/h2/connection.rb +18 -28
- data/lib/seahorse/client/h2/handler.rb +13 -3
- data/lib/seahorse/client/http/response.rb +1 -1
- data/lib/seahorse/client/net_http/connection_pool.rb +12 -3
- data/lib/seahorse/client/net_http/handler.rb +21 -9
- data/lib/seahorse/client/networking_error.rb +1 -1
- data/lib/seahorse/client/plugins/h2.rb +4 -4
- data/lib/seahorse/client/plugins/net_http.rb +9 -0
- data/lib/seahorse/client/request_context.rb +8 -1
- data/lib/seahorse/client/response.rb +2 -0
- data/lib/seahorse/util.rb +2 -1
- data/sig/aws-sdk-core/async_client_stubs.rbs +21 -0
- data/sig/aws-sdk-core/telemetry/base.rbs +46 -0
- data/sig/aws-sdk-core/telemetry/otel.rbs +22 -0
- data/sig/aws-sdk-core/telemetry/span_kind.rbs +15 -0
- data/sig/aws-sdk-core/telemetry/span_status.rbs +24 -0
- data/sig/seahorse/client/async_base.rbs +18 -0
- metadata +61 -19
@@ -20,7 +20,7 @@ module Aws
|
|
20
20
|
def apply(http_req, params)
|
21
21
|
@rules.shape.members.each do |name, ref|
|
22
22
|
value = params[name]
|
23
|
-
next if value.nil?
|
23
|
+
next if value.nil?
|
24
24
|
|
25
25
|
case ref.location
|
26
26
|
when 'header' then apply_header_value(http_req.headers, ref, value)
|
@@ -51,7 +51,7 @@ module Aws
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def list(headers, ref, values)
|
54
|
-
return if
|
54
|
+
return if values.nil?
|
55
55
|
|
56
56
|
member_ref = ref.shape.member
|
57
57
|
values = values.collect do |value|
|
@@ -68,7 +68,7 @@ module Aws
|
|
68
68
|
def apply_header_map(headers, ref, values)
|
69
69
|
prefix = ref.location_name || ''
|
70
70
|
values.each_pair do |name, value|
|
71
|
-
headers["#{prefix}#{name}"]
|
71
|
+
headers["#{prefix}#{name}"] ||= value.to_s
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
@@ -1,18 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative '
|
4
|
-
require_relative 'decoder'
|
3
|
+
require_relative '../cbor'
|
5
4
|
|
6
5
|
module Aws
|
7
|
-
module
|
6
|
+
module RpcV2
|
8
7
|
# Pure Ruby implementation of CBOR encode and decode
|
9
8
|
module CborEngine
|
10
9
|
def self.encode(data)
|
11
|
-
Encoder.new.add(data).bytes
|
10
|
+
Cbor::Encoder.new.add(data).bytes
|
12
11
|
end
|
13
12
|
|
14
13
|
def self.decode(bytes)
|
15
|
-
Decoder.new(bytes.force_encoding(Encoding::BINARY)).decode
|
14
|
+
Cbor::Decoder.new(bytes.force_encoding(Encoding::BINARY)).decode
|
16
15
|
end
|
17
16
|
end
|
18
17
|
end
|
@@ -13,11 +13,13 @@ module Aws
|
|
13
13
|
accept =
|
14
14
|
if eventstream_output?(context)
|
15
15
|
'application/vnd.amazon.eventstream'
|
16
|
+
else
|
17
|
+
'application/cbor'
|
16
18
|
end
|
17
19
|
|
18
20
|
headers = context.http_request.headers
|
19
21
|
headers['Content-Type'] ||= content_type if content_type
|
20
|
-
headers['Accept'] ||= accept
|
22
|
+
headers['Accept'] ||= accept
|
21
23
|
@handler.call(context)
|
22
24
|
end
|
23
25
|
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
module Aws
|
4
4
|
module RpcV2
|
5
|
+
# @api private
|
5
6
|
class ErrorHandler < Aws::ErrorHandler
|
6
7
|
|
7
8
|
def call(context)
|
@@ -27,7 +28,7 @@ module Aws
|
|
27
28
|
end
|
28
29
|
|
29
30
|
def extract_error(body, context)
|
30
|
-
data =
|
31
|
+
data = RpcV2.decode(body)
|
31
32
|
code = error_code(data, context)
|
32
33
|
message = data['message']
|
33
34
|
data = parse_error_data(context, body, code)
|
@@ -37,10 +38,14 @@ module Aws
|
|
37
38
|
end
|
38
39
|
|
39
40
|
def error_code(data, context)
|
41
|
+
# This is not correct per protocol tests. awsQueryError is intended to populate the
|
42
|
+
# error code of the error class. The error class should come from __type. Query and
|
43
|
+
# query compatible services currently have dynamic errors raised from error codes instead
|
44
|
+
# of the modeled error class. However, changing this in this major version would break
|
45
|
+
# existing usage.
|
40
46
|
code =
|
41
47
|
if aws_query_error?(context)
|
42
|
-
|
43
|
-
remove_prefix(error, context)
|
48
|
+
aws_query_error_code(context)
|
44
49
|
else
|
45
50
|
data['__type']
|
46
51
|
end
|
@@ -51,6 +56,25 @@ module Aws
|
|
51
56
|
end
|
52
57
|
end
|
53
58
|
|
59
|
+
def aws_query_error?(context)
|
60
|
+
context.config.api.metadata['awsQueryCompatible'] &&
|
61
|
+
context.http_response.headers['x-amzn-query-error']
|
62
|
+
end
|
63
|
+
|
64
|
+
def aws_query_error_code(context)
|
65
|
+
query_header = context.http_response.headers['x-amzn-query-error']
|
66
|
+
error, _type = query_header.split(';') # type not supported
|
67
|
+
remove_prefix(error, context)
|
68
|
+
end
|
69
|
+
|
70
|
+
def remove_prefix(error_code, context)
|
71
|
+
if (prefix = context.config.api.metadata['errorPrefix'])
|
72
|
+
error_code.sub(/^#{prefix}/, '')
|
73
|
+
else
|
74
|
+
error_code
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
54
78
|
def parse_error_data(context, body, code)
|
55
79
|
data = EmptyStructure.new
|
56
80
|
if (error_rules = context.operation.errors)
|
@@ -66,19 +90,6 @@ module Aws
|
|
66
90
|
end
|
67
91
|
data
|
68
92
|
end
|
69
|
-
|
70
|
-
def aws_query_error?(context)
|
71
|
-
context.config.api.metadata['awsQueryCompatible'] &&
|
72
|
-
context.http_response.headers['x-amzn-query-error']
|
73
|
-
end
|
74
|
-
|
75
|
-
def remove_prefix(error_code, context)
|
76
|
-
if (prefix = context.config.api.metadata['errorPrefix'])
|
77
|
-
error_code.sub(/^#{prefix}/, '')
|
78
|
-
else
|
79
|
-
error_code
|
80
|
-
end
|
81
|
-
end
|
82
93
|
end
|
83
94
|
end
|
84
95
|
end
|
@@ -7,7 +7,7 @@ module Aws
|
|
7
7
|
# @return [Seahorse::Client::Response]
|
8
8
|
def call(context)
|
9
9
|
build_request(context)
|
10
|
-
response = @handler.call(context)
|
10
|
+
response = with_metric { @handler.call(context) }
|
11
11
|
response.on(200..299) { |resp| resp.data = parse_body(context) }
|
12
12
|
response.on(200..599) { |_resp| apply_request_id(context) }
|
13
13
|
response
|
@@ -15,8 +15,13 @@ module Aws
|
|
15
15
|
|
16
16
|
private
|
17
17
|
|
18
|
+
def with_metric(&block)
|
19
|
+
Aws::Plugins::UserAgent.metric('PROTOCOL_RPC_V2_CBOR', &block)
|
20
|
+
end
|
21
|
+
|
18
22
|
def build_request(context)
|
19
|
-
context.http_request.headers['
|
23
|
+
context.http_request.headers['Smithy-Protocol'] = 'rpc-v2-cbor'
|
24
|
+
context.http_request.headers['X-Amzn-Query-Mode'] = 'true' if query_compatible?(context)
|
20
25
|
context.http_request.http_method = 'POST'
|
21
26
|
context.http_request.body = build_body(context)
|
22
27
|
build_url(context)
|
@@ -16,7 +16,7 @@ module Aws
|
|
16
16
|
def parse(cbor, target = nil)
|
17
17
|
return {} if cbor.empty?
|
18
18
|
|
19
|
-
parse_ref(@rules,
|
19
|
+
parse_ref(@rules, RpcV2.decode(cbor), target)
|
20
20
|
end
|
21
21
|
|
22
22
|
private
|
@@ -85,6 +85,14 @@ module Aws
|
|
85
85
|
end
|
86
86
|
end
|
87
87
|
end
|
88
|
+
|
89
|
+
def flattened_list?(shape)
|
90
|
+
shape.is_a?(ListShape) && shape.flattened
|
91
|
+
end
|
92
|
+
|
93
|
+
def flattened_map?(shape)
|
94
|
+
shape.is_a?(MapShape) && shape.flattened
|
95
|
+
end
|
88
96
|
end
|
89
97
|
end
|
90
98
|
end
|
data/lib/aws-sdk-core/rpc_v2.rb
CHANGED
@@ -1,6 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'cbor'
|
2
|
-
require_relative 'rpc_v2/
|
4
|
+
require_relative 'rpc_v2/builder'
|
3
5
|
require_relative 'rpc_v2/content_type_handler'
|
4
6
|
require_relative 'rpc_v2/error_handler'
|
5
|
-
require_relative 'rpc_v2/
|
7
|
+
require_relative 'rpc_v2/handler'
|
6
8
|
require_relative 'rpc_v2/parser'
|
9
|
+
|
10
|
+
module Aws
|
11
|
+
# @api private
|
12
|
+
module RpcV2
|
13
|
+
class << self
|
14
|
+
# @param [Symbol,Class] engine
|
15
|
+
# Must be one of the following values:
|
16
|
+
#
|
17
|
+
# * :cbor
|
18
|
+
#
|
19
|
+
def engine=(engine)
|
20
|
+
@engine = Class === engine ? engine : load_engine(engine)
|
21
|
+
end
|
22
|
+
|
23
|
+
# @return [Class] Returns the default engine.
|
24
|
+
# One of:
|
25
|
+
#
|
26
|
+
# * {CborEngine}
|
27
|
+
#
|
28
|
+
def engine
|
29
|
+
set_default_engine unless @engine
|
30
|
+
@engine
|
31
|
+
end
|
32
|
+
|
33
|
+
def encode(data)
|
34
|
+
@engine.encode(data)
|
35
|
+
end
|
36
|
+
|
37
|
+
def decode(bytes)
|
38
|
+
bytes.force_encoding(Encoding::BINARY)
|
39
|
+
@engine.decode(bytes)
|
40
|
+
end
|
41
|
+
|
42
|
+
def set_default_engine
|
43
|
+
[:cbor].each do |name|
|
44
|
+
@engine ||= try_load_engine(name)
|
45
|
+
end
|
46
|
+
|
47
|
+
unless @engine
|
48
|
+
raise 'Unable to find a compatible cbor library.'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def load_engine(name)
|
55
|
+
require "aws-sdk-core/rpc_v2/#{name}_engine"
|
56
|
+
const_name = name[0].upcase + name[1..-1] + 'Engine'
|
57
|
+
const_get(const_name)
|
58
|
+
end
|
59
|
+
|
60
|
+
def try_load_engine(name)
|
61
|
+
load_engine(name)
|
62
|
+
rescue LoadError
|
63
|
+
false
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
set_default_engine
|
68
|
+
end
|
69
|
+
end
|
@@ -138,7 +138,11 @@ module Aws
|
|
138
138
|
role_session_name: entry['role_session_name']
|
139
139
|
}
|
140
140
|
cfg[:region] = opts[:region] if opts[:region]
|
141
|
-
|
141
|
+
with_metrics('CREDENTIALS_PROFILE_STS_WEB_ID_TOKEN') do
|
142
|
+
creds = AssumeRoleWebIdentityCredentials.new(cfg)
|
143
|
+
creds.metrics << 'CREDENTIALS_PROFILE_STS_WEB_ID_TOKEN'
|
144
|
+
creds
|
145
|
+
end
|
142
146
|
end
|
143
147
|
end
|
144
148
|
end
|
@@ -198,6 +202,7 @@ module Aws
|
|
198
202
|
|
199
203
|
config_reader(
|
200
204
|
:region,
|
205
|
+
:account_id_endpoint_mode,
|
201
206
|
:sigv4a_signing_region_set,
|
202
207
|
:ca_bundle,
|
203
208
|
:credential_process,
|
@@ -207,10 +212,13 @@ module Aws
|
|
207
212
|
:ec2_metadata_service_endpoint,
|
208
213
|
:ec2_metadata_service_endpoint_mode,
|
209
214
|
:ec2_metadata_v1_disabled,
|
215
|
+
:disable_host_prefix_injection,
|
210
216
|
:max_attempts,
|
211
217
|
:retry_mode,
|
212
218
|
:adaptive_retry_wait_to_fill,
|
213
219
|
:correct_clock_skew,
|
220
|
+
:request_checksum_calculation,
|
221
|
+
:response_checksum_validation,
|
214
222
|
:csm_client_id,
|
215
223
|
:csm_enabled,
|
216
224
|
:csm_host,
|
@@ -252,8 +260,8 @@ module Aws
|
|
252
260
|
'provide only source_profile or credential_source, not both.'
|
253
261
|
elsif opts[:source_profile]
|
254
262
|
opts[:visited_profiles] ||= Set.new
|
255
|
-
|
256
|
-
if opts[:credentials]
|
263
|
+
provider = resolve_source_profile(opts[:source_profile], opts)
|
264
|
+
if provider && (opts[:credentials] = provider.credentials)
|
257
265
|
opts[:role_session_name] ||= prof_cfg['role_session_name']
|
258
266
|
opts[:role_session_name] ||= 'default_session'
|
259
267
|
opts[:role_arn] ||= prof_cfg['role_arn']
|
@@ -262,17 +270,28 @@ module Aws
|
|
262
270
|
opts[:serial_number] ||= prof_cfg['mfa_serial']
|
263
271
|
opts[:profile] = opts.delete(:source_profile)
|
264
272
|
opts.delete(:visited_profiles)
|
265
|
-
|
273
|
+
|
274
|
+
metrics = provider.metrics
|
275
|
+
if provider.is_a?(AssumeRoleCredentials)
|
276
|
+
opts[:credentials] = provider
|
277
|
+
metrics.delete('CREDENTIALS_STS_ASSUME_ROLE')
|
278
|
+
else
|
279
|
+
metrics << 'CREDENTIALS_PROFILE_SOURCE_PROFILE'
|
280
|
+
end
|
281
|
+
# Set the original credentials metrics to [] to prevent duplicate metrics during sign plugin
|
282
|
+
opts[:credentials].metrics = []
|
283
|
+
with_metrics(metrics) do
|
284
|
+
creds = AssumeRoleCredentials.new(opts)
|
285
|
+
creds.metrics.push(*metrics)
|
286
|
+
creds
|
287
|
+
end
|
266
288
|
else
|
267
289
|
raise Errors::NoSourceProfileError,
|
268
290
|
"Profile #{profile} has a role_arn, and source_profile, but the"\
|
269
291
|
' source_profile does not have credentials.'
|
270
292
|
end
|
271
293
|
elsif credential_source
|
272
|
-
opts[:credentials] = credentials_from_source(
|
273
|
-
credential_source,
|
274
|
-
chain_config
|
275
|
-
)
|
294
|
+
opts[:credentials] = credentials_from_source(credential_source, chain_config)
|
276
295
|
if opts[:credentials]
|
277
296
|
opts[:role_session_name] ||= prof_cfg['role_session_name']
|
278
297
|
opts[:role_session_name] ||= 'default_session'
|
@@ -281,7 +300,16 @@ module Aws
|
|
281
300
|
opts[:external_id] ||= prof_cfg['external_id']
|
282
301
|
opts[:serial_number] ||= prof_cfg['mfa_serial']
|
283
302
|
opts.delete(:source_profile) # Cleanup
|
284
|
-
|
303
|
+
|
304
|
+
metrics = opts[:credentials].metrics
|
305
|
+
metrics << 'CREDENTIALS_PROFILE_NAMED_PROVIDER'
|
306
|
+
# Set the original credentials metrics to [] to prevent duplicate metrics during sign plugin
|
307
|
+
opts[:credentials].metrics = []
|
308
|
+
with_metrics(metrics) do
|
309
|
+
creds = AssumeRoleCredentials.new(opts)
|
310
|
+
creds.metrics.push(*metrics)
|
311
|
+
creds
|
312
|
+
end
|
285
313
|
else
|
286
314
|
raise Errors::NoSourceCredentials,
|
287
315
|
"Profile #{profile} could not get source credentials from"\
|
@@ -309,12 +337,24 @@ module Aws
|
|
309
337
|
elsif profile_config && profile_config['source_profile']
|
310
338
|
opts.delete(:source_profile)
|
311
339
|
assume_role_credentials_from_config(opts.merge(profile: profile))
|
312
|
-
elsif (provider =
|
313
|
-
provider
|
340
|
+
elsif (provider = assume_role_web_identity_credentials_from_config_with_metrics(opts.merge(profile: profile)))
|
341
|
+
provider if provider.credentials.set?
|
314
342
|
elsif (provider = assume_role_process_credentials_from_config(profile))
|
315
|
-
provider
|
316
|
-
elsif (provider =
|
317
|
-
provider
|
343
|
+
provider if provider.credentials.set?
|
344
|
+
elsif (provider = sso_credentials_from_config_with_metrics(profile))
|
345
|
+
provider if provider.credentials.set?
|
346
|
+
end
|
347
|
+
end
|
348
|
+
|
349
|
+
def assume_role_web_identity_credentials_from_config_with_metrics(opts)
|
350
|
+
with_metrics('CREDENTIALS_PROFILE_SOURCE_PROFILE') do
|
351
|
+
assume_role_web_identity_credentials_from_config(opts)
|
352
|
+
end
|
353
|
+
end
|
354
|
+
|
355
|
+
def sso_credentials_from_config_with_metrics(profile)
|
356
|
+
with_metrics('CREDENTIALS_PROFILE_SOURCE_PROFILE') do
|
357
|
+
sso_credentials_from_config(profile: profile)
|
318
358
|
end
|
319
359
|
end
|
320
360
|
|
@@ -339,7 +379,11 @@ module Aws
|
|
339
379
|
if @parsed_config
|
340
380
|
credential_process ||= @parsed_config.fetch(profile, {})['credential_process']
|
341
381
|
end
|
342
|
-
|
382
|
+
if credential_process
|
383
|
+
creds = ProcessCredentials.new([credential_process])
|
384
|
+
creds.metrics << 'CREDENTIALS_PROFILE_PROCESS'
|
385
|
+
creds
|
386
|
+
end
|
343
387
|
end
|
344
388
|
|
345
389
|
def credentials_from_shared(profile, _opts)
|
@@ -383,13 +427,18 @@ module Aws
|
|
383
427
|
sso_start_url = prof_config['sso_start_url']
|
384
428
|
end
|
385
429
|
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
430
|
+
metric = prof_config['sso_session'] ? 'CREDENTIALS_PROFILE_SSO' : 'CREDENTIALS_PROFILE_SSO_LEGACY'
|
431
|
+
with_metrics(metric) do
|
432
|
+
creds = SSOCredentials.new(
|
433
|
+
sso_account_id: prof_config['sso_account_id'],
|
434
|
+
sso_role_name: prof_config['sso_role_name'],
|
435
|
+
sso_session: prof_config['sso_session'],
|
436
|
+
sso_region: sso_region,
|
437
|
+
sso_start_url: sso_start_url
|
392
438
|
)
|
439
|
+
creds.metrics << metric
|
440
|
+
creds
|
441
|
+
end
|
393
442
|
end
|
394
443
|
end
|
395
444
|
|
@@ -414,8 +463,10 @@ module Aws
|
|
414
463
|
creds = Credentials.new(
|
415
464
|
prof_config['aws_access_key_id'],
|
416
465
|
prof_config['aws_secret_access_key'],
|
417
|
-
prof_config['aws_session_token']
|
466
|
+
prof_config['aws_session_token'],
|
467
|
+
account_id: prof_config['aws_account_id']
|
418
468
|
)
|
469
|
+
creds.metrics = ['CREDENTIALS_PROFILE']
|
419
470
|
creds if creds.set?
|
420
471
|
end
|
421
472
|
|
@@ -476,5 +527,9 @@ module Aws
|
|
476
527
|
|
477
528
|
sso_session
|
478
529
|
end
|
530
|
+
|
531
|
+
def with_metrics(metrics, &block)
|
532
|
+
Aws::Plugins::UserAgent.metric(*metrics, &block)
|
533
|
+
end
|
479
534
|
end
|
480
535
|
end
|
@@ -7,13 +7,6 @@ module Aws
|
|
7
7
|
|
8
8
|
include CredentialProvider
|
9
9
|
|
10
|
-
# @api private
|
11
|
-
KEY_MAP = {
|
12
|
-
'aws_access_key_id' => 'access_key_id',
|
13
|
-
'aws_secret_access_key' => 'secret_access_key',
|
14
|
-
'aws_session_token' => 'session_token',
|
15
|
-
}
|
16
|
-
|
17
10
|
# Constructs a new SharedCredentials object. This will load static
|
18
11
|
# (access_key_id, secret_access_key and session_token) AWS access
|
19
12
|
# credentials from an ini file, which supports profiles. The default
|
@@ -47,6 +40,7 @@ module Aws
|
|
47
40
|
)
|
48
41
|
@credentials = config.credentials(profile: @profile_name)
|
49
42
|
end
|
43
|
+
@metrics = ['CREDENTIALS_CODE']
|
50
44
|
end
|
51
45
|
|
52
46
|
# @return [String]
|
@@ -91,6 +91,7 @@ module Aws
|
|
91
91
|
client_opts[:credentials] = nil
|
92
92
|
@client = Aws::SSO::Client.new(client_opts)
|
93
93
|
end
|
94
|
+
@metrics = ['CREDENTIALS_SSO']
|
94
95
|
else # legacy behavior
|
95
96
|
missing_keys = LEGACY_REQUIRED_OPTS.select { |k| options[k].nil? }
|
96
97
|
unless missing_keys.empty?
|
@@ -111,6 +112,7 @@ module Aws
|
|
111
112
|
client_opts[:credentials] = nil
|
112
113
|
|
113
114
|
@client = options[:client] || Aws::SSO::Client.new(client_opts)
|
115
|
+
@metrics = ['CREDENTIALS_SSO_LEGACY']
|
114
116
|
end
|
115
117
|
|
116
118
|
@async_refresh = true
|
@@ -156,7 +158,8 @@ module Aws
|
|
156
158
|
@credentials = Credentials.new(
|
157
159
|
c.access_key_id,
|
158
160
|
c.secret_access_key,
|
159
|
-
c.session_token
|
161
|
+
c.session_token,
|
162
|
+
account_id: @sso_account_id
|
160
163
|
)
|
161
164
|
@expiration = Time.at(c.expiration / 1000.0)
|
162
165
|
end
|
@@ -3,6 +3,7 @@
|
|
3
3
|
module Aws
|
4
4
|
module Stubbing
|
5
5
|
module Protocols
|
6
|
+
# @api private
|
6
7
|
class EC2
|
7
8
|
|
8
9
|
def stub_data(api, operation, data)
|
@@ -16,17 +17,17 @@ module Aws
|
|
16
17
|
end
|
17
18
|
|
18
19
|
def stub_error(error_code)
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
<ErrorResponse>
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
</ErrorResponse>
|
20
|
+
resp = Seahorse::Client::Http::Response.new
|
21
|
+
resp.status_code = 400
|
22
|
+
resp.body = <<~XML.strip
|
23
|
+
<ErrorResponse>
|
24
|
+
<Error>
|
25
|
+
<Code>#{error_code}</Code>
|
26
|
+
<Message>stubbed-response-error-message</Message>
|
27
|
+
</Error>
|
28
|
+
</ErrorResponse>
|
28
29
|
XML
|
29
|
-
|
30
|
+
resp
|
30
31
|
end
|
31
32
|
|
32
33
|
private
|
@@ -37,7 +38,7 @@ module Aws
|
|
37
38
|
xml.shift
|
38
39
|
xml.pop
|
39
40
|
xmlns = "http://ec2.amazonaws.com/doc/#{api.version}/".inspect
|
40
|
-
xml.unshift(
|
41
|
+
xml.unshift(' <requestId>stubbed-request-id</requestId>')
|
41
42
|
xml.unshift("<#{operation.name}Response xmlns=#{xmlns}>\n")
|
42
43
|
xml.push("</#{operation.name}Response>\n")
|
43
44
|
xml.join
|
@@ -3,27 +3,28 @@
|
|
3
3
|
module Aws
|
4
4
|
module Stubbing
|
5
5
|
module Protocols
|
6
|
+
# @api private
|
6
7
|
class Json
|
7
8
|
|
8
9
|
def stub_data(api, operation, data)
|
9
10
|
resp = Seahorse::Client::Http::Response.new
|
10
11
|
resp.status_code = 200
|
11
|
-
resp.headers[
|
12
|
-
resp.headers[
|
12
|
+
resp.headers['Content-Type'] = content_type(api)
|
13
|
+
resp.headers['x-amzn-RequestId'] = 'stubbed-request-id'
|
13
14
|
resp.body = build_body(operation, data)
|
14
15
|
resp
|
15
16
|
end
|
16
17
|
|
17
18
|
def stub_error(error_code)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
{
|
22
|
-
|
23
|
-
|
24
|
-
}
|
19
|
+
resp = Seahorse::Client::Http::Response.new
|
20
|
+
resp.status_code = 400
|
21
|
+
resp.body = <<~JSON.strip
|
22
|
+
{
|
23
|
+
"code": #{error_code.inspect},
|
24
|
+
"message": "stubbed-response-error-message"
|
25
|
+
}
|
25
26
|
JSON
|
26
|
-
|
27
|
+
resp
|
27
28
|
end
|
28
29
|
|
29
30
|
private
|
@@ -3,6 +3,7 @@
|
|
3
3
|
module Aws
|
4
4
|
module Stubbing
|
5
5
|
module Protocols
|
6
|
+
# @api private
|
6
7
|
class Query
|
7
8
|
|
8
9
|
def stub_data(api, operation, data)
|
@@ -13,10 +14,10 @@ module Aws
|
|
13
14
|
end
|
14
15
|
|
15
16
|
def stub_error(error_code)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
resp = Seahorse::Client::Http::Response.new
|
18
|
+
resp.status_code = 400
|
19
|
+
resp.body = XmlError.new(error_code).to_xml
|
20
|
+
resp
|
20
21
|
end
|
21
22
|
|
22
23
|
private
|
@@ -24,9 +25,9 @@ module Aws
|
|
24
25
|
def build_body(api, operation, data)
|
25
26
|
xml = []
|
26
27
|
builder = Aws::Xml::DocBuilder.new(target: xml, indent: ' ')
|
27
|
-
builder.node(operation.name
|
28
|
+
builder.node("#{operation.name}Response", xmlns: xmlns(api)) do
|
28
29
|
if (rules = operation.output)
|
29
|
-
rules.location_name = operation.name
|
30
|
+
rules.location_name = "#{operation.name}Result"
|
30
31
|
Xml::Builder.new(rules, target: xml, pad:' ').to_xml(data)
|
31
32
|
end
|
32
33
|
builder.node('ResponseMetadata') do
|
@@ -5,6 +5,7 @@ require 'aws-eventstream'
|
|
5
5
|
module Aws
|
6
6
|
module Stubbing
|
7
7
|
module Protocols
|
8
|
+
# @api private
|
8
9
|
class Rest
|
9
10
|
|
10
11
|
include Seahorse::Model::Shapes
|
@@ -22,7 +23,7 @@ module Aws
|
|
22
23
|
def new_http_response
|
23
24
|
resp = Seahorse::Client::Http::Response.new
|
24
25
|
resp.status_code = 200
|
25
|
-
resp.headers[
|
26
|
+
resp.headers['x-amzn-RequestId'] = 'stubbed-request-id'
|
26
27
|
resp
|
27
28
|
end
|
28
29
|
|
@@ -3,6 +3,7 @@
|
|
3
3
|
module Aws
|
4
4
|
module Stubbing
|
5
5
|
module Protocols
|
6
|
+
# @api private
|
6
7
|
class RestJson < Rest
|
7
8
|
|
8
9
|
def body_for(_a, _b, rules, data)
|
@@ -14,15 +15,15 @@ module Aws
|
|
14
15
|
end
|
15
16
|
|
16
17
|
def stub_error(error_code)
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
{
|
21
|
-
|
22
|
-
|
23
|
-
}
|
18
|
+
resp = Seahorse::Client::Http::Response.new
|
19
|
+
resp.status_code = 400
|
20
|
+
resp.body = <<~JSON.strip
|
21
|
+
{
|
22
|
+
"code": #{error_code.inspect},
|
23
|
+
"message": "stubbed-response-error-message"
|
24
|
+
}
|
24
25
|
JSON
|
25
|
-
|
26
|
+
resp
|
26
27
|
end
|
27
28
|
|
28
29
|
end
|