aws-sdk-core 3.201.3 → 3.209.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 (63) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +113 -0
  3. data/VERSION +1 -1
  4. data/lib/aws-defaults.rb +4 -1
  5. data/lib/aws-sdk-core/assume_role_credentials.rb +12 -5
  6. data/lib/aws-sdk-core/assume_role_web_identity_credentials.rb +13 -7
  7. data/lib/aws-sdk-core/client_side_monitoring.rb +9 -0
  8. data/lib/aws-sdk-core/credential_provider_chain.rb +9 -2
  9. data/lib/aws-sdk-core/credentials.rb +13 -6
  10. data/lib/aws-sdk-core/endpoints/endpoint.rb +3 -1
  11. data/lib/aws-sdk-core/endpoints.rb +6 -3
  12. data/lib/aws-sdk-core/log.rb +10 -0
  13. data/lib/aws-sdk-core/plugins/credentials_configuration.rb +7 -3
  14. data/lib/aws-sdk-core/plugins/regional_endpoint.rb +1 -0
  15. data/lib/aws-sdk-core/plugins/sign.rb +2 -3
  16. data/lib/aws-sdk-core/plugins/stub_responses.rb +29 -2
  17. data/lib/aws-sdk-core/plugins/telemetry.rb +75 -0
  18. data/lib/aws-sdk-core/plugins/user_agent.rb +17 -8
  19. data/lib/aws-sdk-core/plugins.rb +39 -0
  20. data/lib/aws-sdk-core/process_credentials.rb +2 -1
  21. data/lib/aws-sdk-core/resources.rb +8 -0
  22. data/lib/aws-sdk-core/rpc_v2/handler.rb +5 -1
  23. data/lib/aws-sdk-core/shared_config.rb +3 -1
  24. data/lib/aws-sdk-core/shared_credentials.rb +0 -7
  25. data/lib/aws-sdk-core/sso_credentials.rb +2 -1
  26. data/lib/aws-sdk-core/stubbing.rb +22 -0
  27. data/lib/aws-sdk-core/telemetry/base.rb +177 -0
  28. data/lib/aws-sdk-core/telemetry/no_op.rb +70 -0
  29. data/lib/aws-sdk-core/telemetry/otel.rb +235 -0
  30. data/lib/aws-sdk-core/telemetry/span_kind.rb +22 -0
  31. data/lib/aws-sdk-core/telemetry/span_status.rb +59 -0
  32. data/lib/aws-sdk-core/telemetry.rb +78 -0
  33. data/lib/aws-sdk-core/waiters/poller.rb +9 -4
  34. data/lib/aws-sdk-core.rb +82 -112
  35. data/lib/aws-sdk-sso/client.rb +35 -8
  36. data/lib/aws-sdk-sso/client_api.rb +1 -0
  37. data/lib/aws-sdk-sso/endpoints.rb +4 -16
  38. data/lib/aws-sdk-sso/plugins/endpoints.rb +18 -6
  39. data/lib/aws-sdk-sso/types.rb +1 -0
  40. data/lib/aws-sdk-sso.rb +15 -11
  41. data/lib/aws-sdk-ssooidc/client.rb +35 -8
  42. data/lib/aws-sdk-ssooidc/client_api.rb +1 -0
  43. data/lib/aws-sdk-ssooidc/endpoints.rb +4 -16
  44. data/lib/aws-sdk-ssooidc/plugins/endpoints.rb +18 -6
  45. data/lib/aws-sdk-ssooidc/types.rb +1 -0
  46. data/lib/aws-sdk-ssooidc.rb +15 -11
  47. data/lib/aws-sdk-sts/client.rb +35 -8
  48. data/lib/aws-sdk-sts/client_api.rb +1 -0
  49. data/lib/aws-sdk-sts/customizations.rb +5 -1
  50. data/lib/aws-sdk-sts/endpoints.rb +8 -32
  51. data/lib/aws-sdk-sts/plugins/endpoints.rb +18 -6
  52. data/lib/aws-sdk-sts/types.rb +1 -0
  53. data/lib/aws-sdk-sts.rb +15 -11
  54. data/lib/seahorse/client/h2/handler.rb +13 -3
  55. data/lib/seahorse/client/net_http/connection_pool.rb +8 -2
  56. data/lib/seahorse/client/net_http/handler.rb +21 -9
  57. data/lib/seahorse/client/plugins/net_http.rb +9 -0
  58. data/lib/seahorse/client/request_context.rb +8 -1
  59. data/sig/aws-sdk-core/telemetry/base.rbs +46 -0
  60. data/sig/aws-sdk-core/telemetry/otel.rbs +22 -0
  61. data/sig/aws-sdk-core/telemetry/span_kind.rbs +15 -0
  62. data/sig/aws-sdk-core/telemetry/span_status.rbs +24 -0
  63. metadata +20 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3242d42e3e0e5e2edc14b5952789ec1dcf2a1a815c2e3378b8c317279cfb4cde
4
- data.tar.gz: ccf76742ca38e548949a69a6d75ad7040e605247b378a597ec6d00336df816f2
3
+ metadata.gz: b21a55766ac3b065464e202f9e5e8eaa449fb1b186776cc439f9ef6859c51923
4
+ data.tar.gz: d0602af7e12f340646722e0ca65ebbe1b9950d8b7ac7da1da2bfaf22a6723fbb
5
5
  SHA512:
6
- metadata.gz: 012726aaef8a0b88c05c1f2168096c9d0f69385f618a1eaba177d949fcf715488d8a7b3475f5eb157f7c0d1a81a7c936851d96f4b25af5a6c1ca329ff98c17ad
7
- data.tar.gz: ab95eaef0edc1d0f0a4c04ffa1a1c401b1caff844e56c000df70a8333af8953f82d89828ad52886a5915842c85528399909c895201f666df04a9f015ca8648e9
6
+ metadata.gz: dce3b13eced2c29beecdbc6929836c9917cc0d7524033cb76e0ea7ae6cf6f01c87b9f0f07a88a17197cb2989c4addf3a9c303acbdb6cf5fb331ecb328d16feec
7
+ data.tar.gz: ace0cb1e6d8e05083601c36607a3c8d6902a72a36cec481081939626ce8399fa43b603b42d6fb026cddce1ec51ab98f405a02e6fa4eb861aabe23aa658519457
data/CHANGELOG.md CHANGED
@@ -1,6 +1,119 @@
1
1
  Unreleased Changes
2
2
  ------------------
3
3
 
4
+ 3.209.1 (2024-09-25)
5
+ ------------------
6
+
7
+ * Issue - Add all core plugins to autoloads.
8
+
9
+ 3.209.0 (2024-09-24)
10
+ ------------------
11
+
12
+ * Feature - Updated Aws::STS::Client with the latest API changes.
13
+
14
+ * Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
15
+
16
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
17
+
18
+ * Issue - Add service identifiers to GlobalConfig's list of identifiers outside of autoload (#3113).
19
+
20
+ * Issue - Ignore invalid ARNs when trying to parse accountId in assume role credentials.
21
+
22
+ 3.208.0 (2024-09-23)
23
+ ------------------
24
+
25
+ * Feature - Updated Aws::STS::Client with the latest API changes.
26
+
27
+ * Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
28
+
29
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
30
+
31
+ * Feature - Use autoloading at the service level to load service clients and resources.
32
+
33
+ 3.207.0 (2024-09-20)
34
+ ------------------
35
+
36
+ * Feature - Updated Aws::STS::Client with the latest API changes.
37
+
38
+ * Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
39
+
40
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
41
+
42
+ * Feature - Support Account ID credentials using `ENV['AWS_ACCOUNT_ID']`, `aws_account_id` shared config, or the `account_id` Client configuration option.
43
+
44
+ * Feature - Support Account ID endpoint mode using `ENV['AWS_ACCOUNT_ID_ENDPOINT_MODE']`, `aws_account_id_endpoint_mode` shared config, or the `account_id_endpoint_mode` Client configuration option. Defaults to `preferred`, which will use the account id endpoint if available. Set to `disabled` to disable account id endpoints. Set to `required` to require account id endpoint usage; an error is raised if credentials do not have an account id.
45
+
46
+ 3.206.0 (2024-09-17)
47
+ ------------------
48
+
49
+ * Feature - Support `sigv4a` endpoint auth without CRT.
50
+
51
+ 3.205.0 (2024-09-11)
52
+ ------------------
53
+
54
+ * Feature - Updated Aws::STS::Client with the latest API changes.
55
+
56
+ * Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
57
+
58
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
59
+
60
+ * Issue - Additional metrics collection in the User-Agent plugin.
61
+
62
+ 3.204.0 (2024-09-10)
63
+ ------------------
64
+
65
+ * Feature - Updated Aws::STS::Client with the latest API changes.
66
+
67
+ * Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
68
+
69
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
70
+
71
+ * Issue - Add support for `ssl_cert` and `ssl_key` configuration options to support mTLS.
72
+
73
+ 3.203.0 (2024-09-03)
74
+ ------------------
75
+
76
+ * Feature - Updated Aws::STS::Client with the latest API changes.
77
+
78
+ * Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
79
+
80
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
81
+
82
+ * Feature - Add support for Observability which includes a configuration, `telemetry_provider` and an OpenTelemetry-based telemetry provider.
83
+
84
+ 3.202.2 (2024-08-30)
85
+ ------------------
86
+
87
+ * Issue - revert auto-loading of bundled gems.
88
+
89
+ 3.202.1 (2024-08-29)
90
+ ------------------
91
+
92
+ * Issue - require default plugins when loading aws-sdk-core.
93
+
94
+ 3.202.0 (2024-08-27)
95
+ ------------------
96
+
97
+ * Feature - Updated Aws::STS::Client with the latest API changes.
98
+
99
+ * Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
100
+
101
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
102
+
103
+ * Issue - Reduce initial memory usage by auto-loading bundled gems (STS, SSO, SSOOIDC).
104
+
105
+ 3.201.5 (2024-08-15)
106
+ ------------------
107
+
108
+ * Issue - Allow legacy/undocumented `sigv4_signer` configuration to override resolved signer.
109
+
110
+ * Issue - Consider sigv4a supported without crt check.
111
+
112
+ 3.201.4 (2024-08-08)
113
+ ------------------
114
+
115
+ * Issue - Update waiters to handle expected boolean values when matching errors.
116
+
4
117
  3.201.3 (2024-07-23)
5
118
  ------------------
6
119
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.201.3
1
+ 3.209.1
data/lib/aws-defaults.rb CHANGED
@@ -1,3 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'aws-defaults/default_configuration'
3
+ module Aws
4
+ autoload :DefaultsModeConfiguration, 'aws-defaults/default_configuration'
5
+ autoload :DefaultsModeConfigResolver, 'aws-defaults/defaults_mode_config_resolver'
6
+ end
@@ -62,13 +62,20 @@ module Aws
62
62
  private
63
63
 
64
64
  def refresh
65
- c = @client.assume_role(@assume_role_params).credentials
65
+ resp = @client.assume_role(@assume_role_params)
66
+ creds = resp.credentials
66
67
  @credentials = Credentials.new(
67
- c.access_key_id,
68
- c.secret_access_key,
69
- c.session_token
68
+ creds.access_key_id,
69
+ creds.secret_access_key,
70
+ creds.session_token,
71
+ account_id: parse_account_id(resp)
70
72
  )
71
- @expiration = c.expiration
73
+ @expiration = creds.expiration
74
+ end
75
+
76
+ def parse_account_id(resp)
77
+ arn = resp.assumed_role_user&.arn
78
+ ARNParser.parse(arn).account_id if ARNParser.arn?(arn)
72
79
  end
73
80
 
74
81
  class << self
@@ -60,7 +60,7 @@ module Aws
60
60
  # not provided, generate encoded UUID as session name
61
61
  @assume_role_web_identity_params[:role_session_name] = _session_name
62
62
  end
63
- @client = client_opts[:client] || STS::Client.new(client_opts.merge(credentials: false))
63
+ @client = client_opts[:client] || STS::Client.new(client_opts.merge(credentials: nil))
64
64
  super
65
65
  end
66
66
 
@@ -73,14 +73,15 @@ module Aws
73
73
  # read from token file everytime it refreshes
74
74
  @assume_role_web_identity_params[:web_identity_token] = _token_from_file(@token_file)
75
75
 
76
- c = @client.assume_role_with_web_identity(
77
- @assume_role_web_identity_params).credentials
76
+ resp = @client.assume_role_with_web_identity(@assume_role_web_identity_params)
77
+ creds = resp.credentials
78
78
  @credentials = Credentials.new(
79
- c.access_key_id,
80
- c.secret_access_key,
81
- c.session_token
79
+ creds.access_key_id,
80
+ creds.secret_access_key,
81
+ creds.session_token,
82
+ account_id: parse_account_id(resp)
82
83
  )
83
- @expiration = c.expiration
84
+ @expiration = creds.expiration
84
85
  end
85
86
 
86
87
  def _token_from_file(path)
@@ -94,6 +95,11 @@ module Aws
94
95
  Base64.strict_encode64(SecureRandom.uuid)
95
96
  end
96
97
 
98
+ def parse_account_id(resp)
99
+ arn = resp.assumed_role_user&.arn
100
+ ARNParser.parse(arn).account_id if ARNParser.arn?(arn)
101
+ end
102
+
97
103
  class << self
98
104
 
99
105
  # @api private
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ # setup autoloading for ClientSideMonitoring module
5
+ module ClientSideMonitoring
6
+ autoload :RequestMetrics, 'aws-sdk-core/client_side_monitoring/request_metrics'
7
+ autoload :Publisher, 'aws-sdk-core/client_side_monitoring/publisher'
8
+ end
9
+ end
@@ -45,7 +45,8 @@ module Aws
45
45
  Credentials.new(
46
46
  options[:config].access_key_id,
47
47
  options[:config].secret_access_key,
48
- options[:config].session_token
48
+ options[:config].session_token,
49
+ account_id: options[:config].account_id
49
50
  )
50
51
  end
51
52
  end
@@ -94,7 +95,13 @@ module Aws
94
95
  key = %w[AWS_ACCESS_KEY_ID AMAZON_ACCESS_KEY_ID AWS_ACCESS_KEY]
95
96
  secret = %w[AWS_SECRET_ACCESS_KEY AMAZON_SECRET_ACCESS_KEY AWS_SECRET_KEY]
96
97
  token = %w[AWS_SESSION_TOKEN AMAZON_SESSION_TOKEN]
97
- Credentials.new(envar(key), envar(secret), envar(token))
98
+ account_id = %w[AWS_ACCOUNT_ID]
99
+ Credentials.new(
100
+ envar(key),
101
+ envar(secret),
102
+ envar(token),
103
+ account_id: envar(account_id)
104
+ )
98
105
  end
99
106
 
100
107
  def envar(keys)
@@ -6,21 +6,28 @@ module Aws
6
6
  # @param [String] access_key_id
7
7
  # @param [String] secret_access_key
8
8
  # @param [String] session_token (nil)
9
- def initialize(access_key_id, secret_access_key, session_token = nil)
9
+ # @param [Hash] kwargs
10
+ # @option kwargs [String] :credential_scope (nil)
11
+ def initialize(access_key_id, secret_access_key, session_token = nil,
12
+ **kwargs)
10
13
  @access_key_id = access_key_id
11
14
  @secret_access_key = secret_access_key
12
15
  @session_token = session_token
16
+ @account_id = kwargs[:account_id]
13
17
  end
14
18
 
15
- # @return [String, nil]
19
+ # @return [String]
16
20
  attr_reader :access_key_id
17
21
 
18
- # @return [String, nil]
22
+ # @return [String]
19
23
  attr_reader :secret_access_key
20
24
 
21
25
  # @return [String, nil]
22
26
  attr_reader :session_token
23
27
 
28
+ # @return [String, nil]
29
+ attr_reader :account_id
30
+
24
31
  # @return [Credentials]
25
32
  def credentials
26
33
  self
@@ -30,9 +37,9 @@ module Aws
30
37
  # access key are both set.
31
38
  def set?
32
39
  !access_key_id.nil? &&
33
- !access_key_id.empty? &&
34
- !secret_access_key.nil? &&
35
- !secret_access_key.empty?
40
+ !access_key_id.empty? &&
41
+ !secret_access_key.nil? &&
42
+ !secret_access_key.empty?
36
43
  end
37
44
 
38
45
  # Removing the secret access key from the default inspect string.
@@ -3,15 +3,17 @@
3
3
  module Aws
4
4
  module Endpoints
5
5
  class Endpoint
6
- def initialize(url:, properties: {}, headers: {})
6
+ def initialize(url:, properties: {}, headers: {}, metadata: {})
7
7
  @url = url
8
8
  @properties = properties
9
9
  @headers = headers
10
+ @metadata = metadata
10
11
  end
11
12
 
12
13
  attr_reader :url
13
14
  attr_reader :properties
14
15
  attr_reader :headers
16
+ attr_reader :metadata
15
17
  end
16
18
  end
17
19
  end
@@ -19,9 +19,12 @@ require 'aws-sigv4'
19
19
  module Aws
20
20
  # @api private
21
21
  module Endpoints
22
- supported_auth_traits = %w[aws.auth#sigv4 smithy.api#httpBearerAuth smithy.api#noAuth]
23
- supported_auth_traits += ['aws.auth#sigv4a'] if Aws::Sigv4::Signer.use_crt?
24
- SUPPORTED_AUTH_TRAITS = supported_auth_traits.freeze
22
+ SUPPORTED_AUTH_TRAITS = %w[
23
+ aws.auth#sigv4
24
+ aws.auth#sigv4a
25
+ smithy.api#httpBearerAuth
26
+ smithy.api#noAuth
27
+ ].freeze
25
28
 
26
29
  class << self
27
30
  def resolve_auth_scheme(context, endpoint)
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ # setup autoloading for Log module
5
+ module Log
6
+ autoload :Formatter, 'aws-sdk-core/log/formatter'
7
+ autoload :ParamFilter, 'aws-sdk-core/log/param_filter'
8
+ autoload :ParamFormatter, 'aws-sdk-core/log/param_formatter'
9
+ end
10
+ end
@@ -12,6 +12,8 @@ module Aws
12
12
 
13
13
  option(:session_token, doc_type: String, docstring: '')
14
14
 
15
+ option(:account_id, doc_type: String, docstring: '')
16
+
15
17
  option(:profile,
16
18
  doc_default: 'default',
17
19
  doc_type: String,
@@ -58,13 +60,15 @@ When `:credentials` are not configured directly, the following
58
60
  locations will be searched for credentials:
59
61
 
60
62
  * `Aws.config[:credentials]`
61
- * The `:access_key_id`, `:secret_access_key`, and `:session_token` options.
62
- * ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY']
63
+ * The `:access_key_id`, `:secret_access_key`, `:session_token`, and
64
+ `:account_id` options.
65
+ * ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY'],
66
+ ENV['AWS_SESSION_TOKEN'], and ENV['AWS_ACCOUNT_ID']
63
67
  * `~/.aws/credentials`
64
68
  * `~/.aws/config`
65
69
  * EC2/ECS IMDS instance profile - When used by default, the timeouts
66
70
  are very aggressive. Construct and pass an instance of
67
- `Aws::InstanceProfileCredentails` or `Aws::ECSCredentials` to
71
+ `Aws::InstanceProfileCredentials` or `Aws::ECSCredentials` to
68
72
  enable retries and extended timeouts. Instance profile credential
69
73
  fetching can be disabled by setting ENV['AWS_EC2_METADATA_DISABLED']
70
74
  to true.
@@ -205,6 +205,7 @@ to test or custom endpoints. This should be a valid HTTP(S) URI.
205
205
  cfg.override_config(:region, new_region)
206
206
  end
207
207
  end
208
+
208
209
  # set a default endpoint in config using legacy (endpoints.json) resolver
209
210
  def resolve_legacy_endpoint(cfg)
210
211
  endpoint_prefix = cfg.api.metadata['endpointPrefix']
@@ -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)
@@ -107,7 +106,7 @@ module Aws
107
106
  auth_scheme['signingRegion']
108
107
  end
109
108
  begin
110
- @signer = Aws::Sigv4::Signer.new(
109
+ @signer = config.sigv4_signer || Aws::Sigv4::Signer.new(
111
110
  service: config.sigv4_name || auth_scheme['signingName'],
112
111
  region: sigv4_overrides[:region] || config.sigv4_region || region,
113
112
  credentials_provider: sigv4_overrides[:credentials] || config.credentials,
@@ -49,6 +49,14 @@ requests are made, and retries are disabled.
49
49
  class Handler < Seahorse::Client::Handler
50
50
 
51
51
  def call(context)
52
+ span_wrapper(context) do
53
+ stub_responses(context)
54
+ end
55
+ end
56
+
57
+ private
58
+
59
+ def stub_responses(context)
52
60
  stub = context.client.next_stub(context)
53
61
  resp = Seahorse::Client::Response.new(context: context)
54
62
  async_mode = context.client.is_a? Seahorse::Client::AsyncBase
@@ -58,8 +66,15 @@ requests are made, and retries are disabled.
58
66
  apply_stub(stub, resp, async_mode)
59
67
  end
60
68
 
61
- async_mode ? Seahorse::Client::AsyncResponse.new(
62
- context: context, stream: context[:input_event_stream_handler].event_emitter.stream, sync_queue: Queue.new) : resp
69
+ if async_mode
70
+ Seahorse::Client::AsyncResponse.new(
71
+ context: context,
72
+ stream: context[:input_event_stream_handler].event_emitter.stream,
73
+ sync_queue: Queue.new
74
+ )
75
+ else
76
+ resp
77
+ end
63
78
  end
64
79
 
65
80
  def apply_stub(stub, response, async_mode = false)
@@ -99,6 +114,18 @@ requests are made, and retries are disabled.
99
114
  http_resp.signal_done
100
115
  end
101
116
 
117
+ def span_wrapper(context, &block)
118
+ context.tracer.in_span(
119
+ 'Handler.StubResponses',
120
+ attributes: Aws::Telemetry.http_request_attrs(context)
121
+ ) do |span|
122
+ block.call.tap do
123
+ span.add_attributes(
124
+ Aws::Telemetry.http_response_attrs(context)
125
+ )
126
+ end
127
+ end
128
+ end
102
129
  end
103
130
  end
104
131
  end
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ module Plugins
5
+ # @api private
6
+ class Telemetry < Seahorse::Client::Plugin
7
+ option(
8
+ :telemetry_provider,
9
+ default: Aws::Telemetry::NoOpTelemetryProvider,
10
+ doc_type: Aws::Telemetry::TelemetryProviderBase,
11
+ rbs_type: Aws::Telemetry::TelemetryProviderBase,
12
+ docstring: <<-DOCS) do |_cfg|
13
+ Allows you to provide a telemetry provider, which is used to
14
+ emit telemetry data. By default, uses `NoOpTelemetryProvider` which
15
+ will not record or emit any telemetry data. The SDK supports the
16
+ following telemetry providers:
17
+
18
+ * OpenTelemetry (OTel) - To use the OTel provider, install and require the
19
+ `opentelemetry-sdk` gem and then, pass in an instance of a
20
+ `Aws::Telemetry::OTelProvider` for telemetry provider.
21
+ DOCS
22
+ Aws::Telemetry::NoOpTelemetryProvider.new
23
+ end
24
+
25
+ def after_initialize(client)
26
+ validate_telemetry_provider(client.config)
27
+ end
28
+
29
+ def validate_telemetry_provider(config)
30
+ unless config.telemetry_provider.is_a?(Aws::Telemetry::TelemetryProviderBase)
31
+ raise ArgumentError,
32
+ 'Must provide a telemetry provider for the '\
33
+ '`telemetry_provider` configuration option.'
34
+ end
35
+ end
36
+
37
+ class Handler < Seahorse::Client::Handler
38
+ def call(context)
39
+ span_wrapper(context) { @handler.call(context) }
40
+ end
41
+
42
+ private
43
+
44
+ def span_wrapper(context, &block)
45
+ service_id = service_id(context)
46
+ attributes = {
47
+ 'rpc.system' => 'aws-api',
48
+ 'rpc.service' => service_id,
49
+ 'rpc.method' => context.operation.name,
50
+ 'code.function' => context.operation_name.to_s,
51
+ 'code.namespace' => 'Aws::Plugins::Telemetry'
52
+ }
53
+ context.tracer.in_span(
54
+ parent_span_name(context, service_id),
55
+ attributes: attributes,
56
+ kind: Aws::Telemetry::SpanKind::CLIENT,
57
+ &block
58
+ )
59
+ end
60
+
61
+ def service_id(context)
62
+ context.config.api.metadata['serviceId'] ||
63
+ context.config.api.metadata['serviceAbbreviation'] ||
64
+ context.config.api.metadata['serviceFullName']
65
+ end
66
+
67
+ def parent_span_name(context, service_id)
68
+ "#{service_id}.#{context.operation.name}".delete(' ')
69
+ end
70
+ end
71
+
72
+ handler(Handler, step: :initialize, priority: 99)
73
+ end
74
+ end
75
+ end
@@ -17,7 +17,15 @@ module Aws
17
17
  "S3_CRYPTO_V2": "I",
18
18
  "S3_EXPRESS_BUCKET": "J",
19
19
  "S3_ACCESS_GRANTS": "K",
20
- "GZIP_REQUEST_COMPRESSION": "L"
20
+ "GZIP_REQUEST_COMPRESSION": "L",
21
+ "PROTOCOL_RPC_V2_CBOR": "M",
22
+ "ENDPOINT_OVERRIDE": "N",
23
+ "ACCOUNT_ID_ENDPOINT": "O",
24
+ "ACCOUNT_ID_MODE_PREFERRED": "P",
25
+ "ACCOUNT_ID_MODE_DISABLED": "Q",
26
+ "ACCOUNT_ID_MODE_REQUIRED": "R",
27
+ "SIGV4A_SIGNING": "S",
28
+ "RESOLVED_ACCOUNT_ID": "T"
21
29
  }
22
30
  METRICS
23
31
 
@@ -45,15 +53,13 @@ variable AWS_SDK_UA_APP_ID or the shared config profile attribute sdk_ua_app_id.
45
53
  block.call
46
54
  end
47
55
 
48
- def self.metric(metric, &block)
56
+ def self.metric(*metrics, &block)
49
57
  Thread.current[:aws_sdk_core_user_agent_metric] ||= []
50
- Thread.current[:aws_sdk_core_user_agent_metric] << METRICS[metric]
58
+ metrics = metrics.map { |metric| METRICS[metric] }.compact
59
+ Thread.current[:aws_sdk_core_user_agent_metric].concat(metrics)
51
60
  block.call
52
61
  ensure
53
- Thread.current[:aws_sdk_core_user_agent_metric].pop
54
- if Thread.current[:aws_sdk_core_user_agent_metric].empty?
55
- Thread.current[:aws_sdk_core_user_agent_metric] = nil
56
- end
62
+ Thread.current[:aws_sdk_core_user_agent_metric].pop(metrics.size)
57
63
  end
58
64
 
59
65
  # @api private
@@ -166,7 +172,10 @@ variable AWS_SDK_UA_APP_ID or the shared config profile attribute sdk_ua_app_id.
166
172
  end
167
173
 
168
174
  def metric_metadata
169
- return unless Thread.current[:aws_sdk_core_user_agent_metric]
175
+ if Thread.current[:aws_sdk_core_user_agent_metric].nil? ||
176
+ Thread.current[:aws_sdk_core_user_agent_metric].empty?
177
+ return
178
+ end
170
179
 
171
180
  metrics = Thread.current[:aws_sdk_core_user_agent_metric].join(',')
172
181
  # Metric metadata is limited to 1024 bytes
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ # setup autoloading for Plugins
5
+ # Most plugins are required explicitly from service clients
6
+ # but users may reference them outside of client usage.
7
+ module Plugins
8
+ autoload :ApiKey, 'aws-sdk-core/plugins/api_key'
9
+ autoload :BearerAuthorization, 'aws-sdk-core/plugins/bearer_authorization'
10
+ autoload :ChecksumAlgorithm, 'aws-sdk-core/plugins/checksum_algorithm'
11
+ autoload :ClientMetricsPlugin, 'aws-sdk-core/plugins/client_metrics_plugin'
12
+ autoload :ClientMetricsSendPlugin, 'aws-sdk-core/plugins/client_metrics_send_plugin'
13
+ autoload :CredentialsConfiguration, 'aws-sdk-core/plugins/credentials_configuration'
14
+ autoload :DefaultsMode, 'aws-sdk-core/plugins/defaults_mode'
15
+ autoload :EndpointDiscovery, 'aws-sdk-core/plugins/endpoint_discovery'
16
+ autoload :EndpointPattern, 'aws-sdk-core/plugins/endpoint_pattern'
17
+ autoload :EventStreamConfiguration, 'aws-sdk-core/plugins/event_stream_configuration'
18
+ autoload :GlobalConfiguration, 'aws-sdk-core/plugins/global_configuration'
19
+ autoload :HelpfulSocketErrors, 'aws-sdk-core/plugins/helpful_socket_errors'
20
+ autoload :HttpChecksum, 'aws-sdk-core/plugins/http_checksum'
21
+ autoload :IdempotencyToken, 'aws-sdk-core/plugins/idempotency_token'
22
+ autoload :InvocationId, 'aws-sdk-core/plugins/invocation_id'
23
+ autoload :JsonvalueConverter, 'aws-sdk-core/plugins/jsonvalue_converter'
24
+ autoload :Logging, 'aws-sdk-core/plugins/logging'
25
+ autoload :ParamConverter, 'aws-sdk-core/plugins/param_converter'
26
+ autoload :ParamValidator, 'aws-sdk-core/plugins/param_validator'
27
+ autoload :RecursionDetection, 'aws-sdk-core/plugins/recursion_detection'
28
+ autoload :RegionalEndpoint, 'aws-sdk-core/plugins/regional_endpoint'
29
+ autoload :RequestCompression, 'aws-sdk-core/plugins/request_compression'
30
+ autoload :ResponsePaging, 'aws-sdk-core/plugins/response_paging'
31
+ autoload :RetryErrors, 'aws-sdk-core/plugins/retry_errors'
32
+ autoload :Sign, 'aws-sdk-core/plugins/sign'
33
+ autoload :SignatureV4, 'aws-sdk-core/plugins/signature_v4'
34
+ autoload :StubResponses, 'aws-sdk-core/plugins/stub_responses'
35
+ autoload :Telemetry, 'aws-sdk-core/plugins/telemetry'
36
+ autoload :TransferEncoding, 'aws-sdk-core/plugins/transfer_encoding'
37
+ autoload :UserAgent, 'aws-sdk-core/plugins/user_agent'
38
+ end
39
+ end
@@ -74,7 +74,8 @@ module Aws
74
74
  creds = Credentials.new(
75
75
  creds_json['AccessKeyId'],
76
76
  creds_json['SecretAccessKey'],
77
- creds_json['SessionToken']
77
+ creds_json['SessionToken'],
78
+ account_id: creds_json['AccountId']
78
79
  )
79
80
 
80
81
  @expiration = creds_json['Expiration'] ? Time.iso8601(creds_json['Expiration']) : nil
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ # setup autoloading for Resources module
5
+ module Resources
6
+ autoload :Collection, 'aws-sdk-core/resources/collection'
7
+ end
8
+ 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,6 +15,10 @@ 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
23
  context.http_request.headers['smithy-protocol'] = 'rpc-v2-cbor'
20
24
  context.http_request.http_method = 'POST'