aws-sdk-core 3.173.0 → 3.254.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +947 -0
- data/VERSION +1 -1
- data/lib/aws-defaults/default_configuration.rb +5 -6
- 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 +21 -13
- data/lib/aws-sdk-core/assume_role_web_identity_credentials.rb +16 -9
- data/lib/aws-sdk-core/binary/decode_handler.rb +3 -9
- data/lib/aws-sdk-core/binary/encode_handler.rb +1 -1
- data/lib/aws-sdk-core/binary/event_builder.rb +34 -37
- data/lib/aws-sdk-core/binary/event_stream_decoder.rb +1 -0
- data/lib/aws-sdk-core/binary/event_stream_encoder.rb +4 -3
- data/lib/aws-sdk-core/cbor/decoder.rb +309 -0
- data/lib/aws-sdk-core/cbor/encoder.rb +243 -0
- data/lib/aws-sdk-core/cbor.rb +53 -0
- data/lib/aws-sdk-core/client_side_monitoring.rb +9 -0
- data/lib/aws-sdk-core/client_stubs.rb +39 -55
- data/lib/aws-sdk-core/credential_provider.rb +8 -1
- data/lib/aws-sdk-core/credential_provider_chain.rb +101 -25
- data/lib/aws-sdk-core/credentials.rb +19 -6
- data/lib/aws-sdk-core/ec2_metadata.rb +1 -1
- data/lib/aws-sdk-core/ecs_credentials.rb +104 -26
- data/lib/aws-sdk-core/endpoints/endpoint.rb +3 -1
- data/lib/aws-sdk-core/endpoints/matchers.rb +21 -19
- data/lib/aws-sdk-core/endpoints.rb +106 -22
- data/lib/aws-sdk-core/error_handler.rb +46 -0
- data/lib/aws-sdk-core/errors.rb +17 -5
- data/lib/aws-sdk-core/event_emitter.rb +1 -17
- data/lib/aws-sdk-core/ini_parser.rb +7 -0
- data/lib/aws-sdk-core/instance_profile_credentials.rb +181 -158
- data/lib/aws-sdk-core/json/builder.rb +23 -1
- data/lib/aws-sdk-core/json/error_handler.rb +31 -14
- data/lib/aws-sdk-core/json/handler.rb +13 -6
- data/lib/aws-sdk-core/json/json_engine.rb +3 -1
- data/lib/aws-sdk-core/json/oj_engine.rb +7 -1
- data/lib/aws-sdk-core/json/parser.rb +33 -3
- data/lib/aws-sdk-core/json.rb +43 -14
- data/lib/aws-sdk-core/log/param_filter.rb +2 -2
- 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/login_credentials.rb +230 -0
- data/lib/aws-sdk-core/lru_cache.rb +75 -0
- data/lib/aws-sdk-core/pageable_response.rb +3 -1
- data/lib/aws-sdk-core/param_validator.rb +9 -4
- data/lib/aws-sdk-core/plugins/bearer_authorization.rb +2 -0
- data/lib/aws-sdk-core/plugins/checksum_algorithm.rb +437 -201
- data/lib/aws-sdk-core/plugins/client_metrics_plugin.rb +1 -1
- data/lib/aws-sdk-core/plugins/client_metrics_send_plugin.rb +14 -2
- data/lib/aws-sdk-core/plugins/credentials_configuration.rb +78 -56
- data/lib/aws-sdk-core/plugins/endpoint_pattern.rb +40 -32
- data/lib/aws-sdk-core/plugins/global_configuration.rb +8 -9
- data/lib/aws-sdk-core/plugins/http_checksum.rb +3 -8
- data/lib/aws-sdk-core/plugins/invocation_id.rb +1 -11
- data/lib/aws-sdk-core/plugins/logging.rb +2 -0
- data/lib/aws-sdk-core/plugins/protocols/api_gateway.rb +3 -1
- data/lib/aws-sdk-core/plugins/protocols/ec2.rb +2 -24
- data/lib/aws-sdk-core/plugins/protocols/json_rpc.rb +6 -8
- data/lib/aws-sdk-core/plugins/protocols/query.rb +4 -2
- data/lib/aws-sdk-core/plugins/protocols/rest_json.rb +3 -15
- data/lib/aws-sdk-core/plugins/protocols/rest_xml.rb +3 -0
- data/lib/aws-sdk-core/plugins/protocols/rpc_v2.rb +17 -0
- data/lib/aws-sdk-core/plugins/regional_endpoint.rb +162 -37
- data/lib/aws-sdk-core/plugins/request_compression.rb +226 -0
- data/lib/aws-sdk-core/plugins/retries/clock_skew.rb +28 -16
- data/lib/aws-sdk-core/plugins/retries/retry_quota.rb +11 -8
- data/lib/aws-sdk-core/plugins/retry_errors.rb +211 -110
- data/lib/aws-sdk-core/plugins/sign.rb +55 -33
- data/lib/aws-sdk-core/plugins/signature_v2.rb +2 -1
- data/lib/aws-sdk-core/plugins/signature_v4.rb +2 -1
- data/lib/aws-sdk-core/plugins/stub_responses.rb +59 -9
- data/lib/aws-sdk-core/plugins/telemetry.rb +75 -0
- data/lib/aws-sdk-core/plugins/transfer_encoding.rb +16 -9
- data/lib/aws-sdk-core/plugins/user_agent.rb +205 -14
- data/lib/aws-sdk-core/plugins.rb +39 -0
- data/lib/aws-sdk-core/process_credentials.rb +48 -29
- data/lib/aws-sdk-core/query/ec2_handler.rb +27 -0
- data/lib/aws-sdk-core/query/ec2_param_builder.rb +5 -7
- data/lib/aws-sdk-core/query/handler.rb +4 -4
- data/lib/aws-sdk-core/query/param_builder.rb +2 -2
- data/lib/aws-sdk-core/query.rb +2 -1
- data/lib/aws-sdk-core/refreshing_credentials.rb +20 -23
- data/lib/aws-sdk-core/resources.rb +8 -0
- data/lib/aws-sdk-core/rest/content_type_handler.rb +60 -0
- data/lib/aws-sdk-core/rest/handler.rb +3 -4
- data/lib/aws-sdk-core/rest/request/body.rb +32 -5
- data/lib/aws-sdk-core/rest/request/endpoint.rb +24 -4
- data/lib/aws-sdk-core/rest/request/headers.rb +15 -7
- data/lib/aws-sdk-core/rest/request/querystring_builder.rb +62 -36
- data/lib/aws-sdk-core/rest/response/body.rb +15 -1
- data/lib/aws-sdk-core/rest/response/header_list_parser.rb +79 -0
- data/lib/aws-sdk-core/rest/response/headers.rb +8 -3
- data/lib/aws-sdk-core/rest.rb +1 -0
- data/lib/aws-sdk-core/rpc_v2/builder.rb +62 -0
- data/lib/aws-sdk-core/rpc_v2/cbor_engine.rb +18 -0
- data/lib/aws-sdk-core/rpc_v2/content_type_handler.rb +47 -0
- data/lib/aws-sdk-core/rpc_v2/error_handler.rb +95 -0
- data/lib/aws-sdk-core/rpc_v2/handler.rb +79 -0
- data/lib/aws-sdk-core/rpc_v2/parser.rb +98 -0
- data/lib/aws-sdk-core/rpc_v2.rb +69 -0
- data/lib/aws-sdk-core/shared_config.rb +155 -39
- data/lib/aws-sdk-core/shared_credentials.rb +1 -7
- data/lib/aws-sdk-core/sso_credentials.rb +6 -3
- data/lib/aws-sdk-core/sso_token_provider.rb +1 -0
- data/lib/aws-sdk-core/static_token_provider.rb +1 -2
- 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 +39 -0
- data/lib/aws-sdk-core/stubbing/stub_data.rb +11 -0
- 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/token.rb +3 -3
- data/lib/aws-sdk-core/token_provider.rb +4 -0
- data/lib/aws-sdk-core/token_provider_chain.rb +2 -6
- data/lib/aws-sdk-core/util.rb +41 -1
- data/lib/aws-sdk-core/waiters/poller.rb +12 -5
- data/lib/aws-sdk-core/xml/builder.rb +17 -9
- data/lib/aws-sdk-core/xml/error_handler.rb +35 -43
- data/lib/aws-sdk-core/xml/parser/frame.rb +4 -20
- data/lib/aws-sdk-core/xml/parser/stack.rb +2 -0
- data/lib/aws-sdk-core/xml/parser.rb +2 -6
- data/lib/aws-sdk-core.rb +86 -107
- data/lib/aws-sdk-signin/client.rb +1008 -0
- data/lib/aws-sdk-signin/client_api.rb +444 -0
- data/lib/aws-sdk-signin/customizations.rb +1 -0
- data/lib/aws-sdk-signin/endpoint_parameters.rb +85 -0
- data/lib/aws-sdk-signin/endpoint_provider.rb +107 -0
- data/lib/aws-sdk-signin/endpoints.rb +133 -0
- data/lib/aws-sdk-signin/errors.rb +185 -0
- data/lib/aws-sdk-signin/plugins/endpoints.rb +77 -0
- data/lib/aws-sdk-signin/resource.rb +26 -0
- data/lib/aws-sdk-signin/types.rb +909 -0
- data/lib/aws-sdk-signin.rb +63 -0
- data/lib/aws-sdk-sso/client.rb +210 -99
- data/lib/aws-sdk-sso/client_api.rb +7 -0
- data/lib/aws-sdk-sso/endpoint_parameters.rb +13 -10
- data/lib/aws-sdk-sso/endpoint_provider.rb +30 -28
- data/lib/aws-sdk-sso/endpoints.rb +3 -54
- data/lib/aws-sdk-sso/plugins/endpoints.rb +23 -22
- data/lib/aws-sdk-sso/types.rb +1 -0
- data/lib/aws-sdk-sso.rb +15 -11
- data/lib/aws-sdk-ssooidc/client.rb +630 -132
- data/lib/aws-sdk-ssooidc/client_api.rb +94 -1
- data/lib/aws-sdk-ssooidc/endpoint_parameters.rb +13 -10
- data/lib/aws-sdk-ssooidc/endpoint_provider.rb +30 -28
- data/lib/aws-sdk-ssooidc/endpoints.rb +3 -40
- data/lib/aws-sdk-ssooidc/errors.rb +62 -0
- data/lib/aws-sdk-ssooidc/plugins/endpoints.rb +23 -20
- data/lib/aws-sdk-ssooidc/types.rb +419 -53
- data/lib/aws-sdk-ssooidc.rb +15 -11
- data/lib/aws-sdk-sts/client.rb +567 -158
- data/lib/aws-sdk-sts/client_api.rb +120 -9
- data/lib/aws-sdk-sts/customizations.rb +5 -2
- data/lib/aws-sdk-sts/endpoint_parameters.rb +15 -14
- data/lib/aws-sdk-sts/endpoint_provider.rb +52 -57
- data/lib/aws-sdk-sts/endpoints.rb +3 -118
- data/lib/aws-sdk-sts/errors.rb +79 -0
- data/lib/aws-sdk-sts/plugins/endpoints.rb +23 -30
- data/lib/aws-sdk-sts/presigner.rb +3 -7
- data/lib/aws-sdk-sts/types.rb +382 -31
- data/lib/aws-sdk-sts.rb +15 -11
- data/lib/seahorse/client/async_base.rb +4 -5
- data/lib/seahorse/client/async_response.rb +19 -0
- data/lib/seahorse/client/base.rb +18 -21
- data/lib/seahorse/client/configuration.rb +0 -4
- data/lib/seahorse/client/h2/connection.rb +18 -28
- data/lib/seahorse/client/h2/handler.rb +19 -3
- data/lib/seahorse/client/handler.rb +1 -1
- data/lib/seahorse/client/http/response.rb +1 -1
- data/lib/seahorse/client/net_http/connection_pool.rb +15 -12
- data/lib/seahorse/client/net_http/handler.rb +21 -9
- data/lib/seahorse/client/net_http/patches.rb +44 -14
- data/lib/seahorse/client/networking_error.rb +1 -1
- data/lib/seahorse/client/plugin.rb +9 -0
- data/lib/seahorse/client/plugins/endpoint.rb +0 -1
- data/lib/seahorse/client/plugins/h2.rb +4 -4
- data/lib/seahorse/client/plugins/net_http.rb +57 -16
- data/lib/seahorse/client/plugins/request_callback.rb +31 -0
- data/lib/seahorse/client/request_context.rb +9 -2
- data/lib/seahorse/client/response.rb +8 -0
- data/lib/seahorse/model/operation.rb +3 -0
- data/lib/seahorse/model/shapes.rb +2 -2
- data/lib/seahorse/util.rb +2 -1
- data/sig/aws-sdk-core/async_client_stubs.rbs +21 -0
- data/sig/aws-sdk-core/client_stubs.rbs +10 -0
- data/sig/aws-sdk-core/errors.rbs +22 -0
- data/sig/aws-sdk-core/resources/collection.rbs +21 -0
- data/sig/aws-sdk-core/structure.rbs +4 -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/aws-sdk-core/waiters/errors.rbs +20 -0
- data/sig/aws-sdk-core.rbs +7 -0
- data/sig/seahorse/client/async_base.rbs +18 -0
- data/sig/seahorse/client/base.rbs +25 -0
- data/sig/seahorse/client/handler_builder.rbs +16 -0
- data/sig/seahorse/client/response.rbs +61 -0
- metadata +118 -23
- /data/lib/aws-sdk-core/xml/parser/{engines/libxml.rb → libxml_engine.rb} +0 -0
- /data/lib/aws-sdk-core/xml/parser/{engines/nokogiri.rb → nokogiri_engine.rb} +0 -0
- /data/lib/aws-sdk-core/xml/parser/{engines/oga.rb → oga_engine.rb} +0 -0
- /data/lib/aws-sdk-core/xml/parser/{engines/ox.rb → ox_engine.rb} +0 -0
- /data/lib/aws-sdk-core/xml/parser/{engines/rexml.rb → rexml_engine.rb} +0 -0
|
@@ -11,7 +11,7 @@ module Aws
|
|
|
11
11
|
def resolve
|
|
12
12
|
providers.each do |method_name, options|
|
|
13
13
|
provider = send(method_name, options.merge(config: @config))
|
|
14
|
-
return provider if provider
|
|
14
|
+
return provider if provider&.set?
|
|
15
15
|
end
|
|
16
16
|
nil
|
|
17
17
|
end
|
|
@@ -25,12 +25,14 @@ module Aws
|
|
|
25
25
|
[:static_profile_sso_credentials, {}],
|
|
26
26
|
[:static_profile_assume_role_credentials, {}],
|
|
27
27
|
[:static_profile_credentials, {}],
|
|
28
|
+
[:static_profile_login_credentials, {}],
|
|
28
29
|
[:static_profile_process_credentials, {}],
|
|
29
30
|
[:env_credentials, {}],
|
|
30
31
|
[:assume_role_web_identity_credentials, {}],
|
|
31
32
|
[:sso_credentials, {}],
|
|
32
33
|
[:assume_role_credentials, {}],
|
|
33
34
|
[:shared_credentials, {}],
|
|
35
|
+
[:login_credentials, {}],
|
|
34
36
|
[:process_credentials, {}],
|
|
35
37
|
[:instance_profile_credentials, {
|
|
36
38
|
retries: @config ? @config.instance_profile_credentials_retries : 0,
|
|
@@ -42,50 +44,92 @@ module Aws
|
|
|
42
44
|
|
|
43
45
|
def static_credentials(options)
|
|
44
46
|
if options[:config]
|
|
45
|
-
Credentials.new(
|
|
47
|
+
creds = Credentials.new(
|
|
46
48
|
options[:config].access_key_id,
|
|
47
49
|
options[:config].secret_access_key,
|
|
48
|
-
options[:config].session_token
|
|
50
|
+
options[:config].session_token,
|
|
51
|
+
account_id: options[:config].account_id
|
|
49
52
|
)
|
|
53
|
+
creds.metrics = ['CREDENTIALS_PROFILE']
|
|
54
|
+
creds
|
|
50
55
|
end
|
|
51
56
|
end
|
|
52
57
|
|
|
53
58
|
def static_profile_assume_role_web_identity_credentials(options)
|
|
54
|
-
|
|
55
|
-
|
|
59
|
+
return unless Aws.shared_config.config_enabled? && options[:config]&.profile
|
|
60
|
+
|
|
61
|
+
with_metrics('CREDENTIALS_CODE') do
|
|
62
|
+
creds = Aws.shared_config.assume_role_web_identity_credentials_from_config(
|
|
56
63
|
profile: options[:config].profile,
|
|
57
64
|
region: options[:config].region
|
|
58
65
|
)
|
|
66
|
+
return unless creds
|
|
67
|
+
|
|
68
|
+
creds.metrics << 'CREDENTIALS_CODE'
|
|
69
|
+
creds
|
|
59
70
|
end
|
|
60
71
|
end
|
|
61
72
|
|
|
62
73
|
def static_profile_sso_credentials(options)
|
|
63
|
-
|
|
64
|
-
|
|
74
|
+
return unless Aws.shared_config.config_enabled? && options[:config]&.profile
|
|
75
|
+
|
|
76
|
+
with_metrics('CREDENTIALS_CODE') do
|
|
77
|
+
creds = Aws.shared_config.sso_credentials_from_config(
|
|
65
78
|
profile: options[:config].profile
|
|
66
79
|
)
|
|
80
|
+
return unless creds
|
|
81
|
+
|
|
82
|
+
creds.metrics << 'CREDENTIALS_CODE'
|
|
83
|
+
creds
|
|
67
84
|
end
|
|
68
85
|
end
|
|
69
86
|
|
|
70
87
|
def static_profile_assume_role_credentials(options)
|
|
71
|
-
|
|
72
|
-
|
|
88
|
+
return unless Aws.shared_config.config_enabled? && options[:config]&.profile
|
|
89
|
+
|
|
90
|
+
with_metrics('CREDENTIALS_CODE') do
|
|
91
|
+
creds = assume_role_with_profile(options, options[:config].profile)
|
|
92
|
+
return unless creds
|
|
93
|
+
|
|
94
|
+
creds.metrics << 'CREDENTIALS_CODE'
|
|
95
|
+
creds
|
|
73
96
|
end
|
|
74
97
|
end
|
|
75
98
|
|
|
76
99
|
def static_profile_credentials(options)
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
100
|
+
return unless options[:config]&.profile
|
|
101
|
+
|
|
102
|
+
creds = SharedCredentials.new(profile_name: options[:config].profile)
|
|
103
|
+
creds.metrics << 'CREDENTIALS_PROFILE'
|
|
104
|
+
creds
|
|
80
105
|
rescue Errors::NoSuchProfileError
|
|
81
106
|
nil
|
|
82
107
|
end
|
|
83
108
|
|
|
84
|
-
def
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
109
|
+
def static_profile_login_credentials(options)
|
|
110
|
+
return unless Aws.shared_config.config_enabled? && options[:config]&.profile
|
|
111
|
+
|
|
112
|
+
with_metrics('CREDENTIALS_CODE') do
|
|
113
|
+
creds = Aws.shared_config.login_credentials_from_config(
|
|
114
|
+
profile: options[:config].profile,
|
|
115
|
+
region: options[:config].region
|
|
116
|
+
)
|
|
117
|
+
return unless creds
|
|
118
|
+
|
|
119
|
+
creds.metrics << 'CREDENTIALS_CODE'
|
|
120
|
+
creds
|
|
88
121
|
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def static_profile_process_credentials(options)
|
|
125
|
+
return unless Aws.shared_config.config_enabled? && options[:config]&.profile
|
|
126
|
+
|
|
127
|
+
process_provider = Aws.shared_config.credential_process(profile: options[:config].profile)
|
|
128
|
+
return unless process_provider
|
|
129
|
+
|
|
130
|
+
creds = ProcessCredentials.new([process_provider])
|
|
131
|
+
creds.metrics.concat(%w[CREDENTIALS_PROFILE_PROCESS CREDENTIALS_CODE])
|
|
132
|
+
creds
|
|
89
133
|
rescue Errors::NoSuchProfileError
|
|
90
134
|
nil
|
|
91
135
|
end
|
|
@@ -94,7 +138,15 @@ module Aws
|
|
|
94
138
|
key = %w[AWS_ACCESS_KEY_ID AMAZON_ACCESS_KEY_ID AWS_ACCESS_KEY]
|
|
95
139
|
secret = %w[AWS_SECRET_ACCESS_KEY AMAZON_SECRET_ACCESS_KEY AWS_SECRET_KEY]
|
|
96
140
|
token = %w[AWS_SESSION_TOKEN AMAZON_SESSION_TOKEN]
|
|
97
|
-
|
|
141
|
+
account_id = %w[AWS_ACCOUNT_ID]
|
|
142
|
+
creds = Credentials.new(
|
|
143
|
+
envar(key),
|
|
144
|
+
envar(secret),
|
|
145
|
+
envar(token),
|
|
146
|
+
account_id: envar(account_id)
|
|
147
|
+
)
|
|
148
|
+
creds.metrics = ['CREDENTIALS_ENV_VARS']
|
|
149
|
+
creds
|
|
98
150
|
end
|
|
99
151
|
|
|
100
152
|
def envar(keys)
|
|
@@ -105,21 +157,37 @@ module Aws
|
|
|
105
157
|
end
|
|
106
158
|
|
|
107
159
|
def determine_profile_name(options)
|
|
108
|
-
(options[:config]
|
|
160
|
+
(options[:config]&.profile) || ENV['AWS_PROFILE'] || ENV['AWS_DEFAULT_PROFILE'] || 'default'
|
|
109
161
|
end
|
|
110
162
|
|
|
111
163
|
def shared_credentials(options)
|
|
112
164
|
profile_name = determine_profile_name(options)
|
|
113
|
-
SharedCredentials.new(profile_name: profile_name)
|
|
165
|
+
creds = SharedCredentials.new(profile_name: profile_name)
|
|
166
|
+
creds.metrics = ['CREDENTIALS_PROFILE']
|
|
167
|
+
creds
|
|
168
|
+
rescue Errors::NoSuchProfileError
|
|
169
|
+
nil
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
def login_credentials(options)
|
|
173
|
+
return unless Aws.shared_config.config_enabled?
|
|
174
|
+
|
|
175
|
+
profile_name = determine_profile_name(options)
|
|
176
|
+
region = options[:config].region if options[:config]
|
|
177
|
+
Aws.shared_config.login_credentials_from_config(profile: profile_name, region: region)
|
|
114
178
|
rescue Errors::NoSuchProfileError
|
|
115
179
|
nil
|
|
116
180
|
end
|
|
117
181
|
|
|
118
182
|
def process_credentials(options)
|
|
119
183
|
profile_name = determine_profile_name(options)
|
|
120
|
-
if Aws.shared_config.config_enabled?
|
|
121
|
-
|
|
122
|
-
|
|
184
|
+
if Aws.shared_config.config_enabled?
|
|
185
|
+
process_provider = Aws.shared_config.credential_process(profile: profile_name)
|
|
186
|
+
if process_provider
|
|
187
|
+
creds = ProcessCredentials.new([process_provider])
|
|
188
|
+
creds.metrics << 'CREDENTIALS_PROFILE_PROCESS'
|
|
189
|
+
creds
|
|
190
|
+
end
|
|
123
191
|
end
|
|
124
192
|
rescue Errors::NoSuchProfileError
|
|
125
193
|
nil
|
|
@@ -149,7 +217,11 @@ module Aws
|
|
|
149
217
|
role_session_name: ENV['AWS_ROLE_SESSION_NAME']
|
|
150
218
|
}
|
|
151
219
|
cfg[:region] = region if region
|
|
152
|
-
|
|
220
|
+
Aws::Plugins::UserAgent.metric('CREDENTIALS_ENV_VARS_STS_WEB_ID_TOKEN') do
|
|
221
|
+
creds = AssumeRoleWebIdentityCredentials.new(cfg)
|
|
222
|
+
creds.metrics << 'CREDENTIALS_ENV_VARS_STS_WEB_ID_TOKEN'
|
|
223
|
+
creds
|
|
224
|
+
end
|
|
153
225
|
elsif Aws.shared_config.config_enabled?
|
|
154
226
|
profile = options[:config].profile if options[:config]
|
|
155
227
|
Aws.shared_config.assume_role_web_identity_credentials_from_config(
|
|
@@ -164,7 +236,7 @@ module Aws
|
|
|
164
236
|
if ENV['AWS_CONTAINER_CREDENTIALS_RELATIVE_URI'] ||
|
|
165
237
|
ENV['AWS_CONTAINER_CREDENTIALS_FULL_URI']
|
|
166
238
|
ECSCredentials.new(options)
|
|
167
|
-
|
|
239
|
+
elsif !(ENV.fetch('AWS_EC2_METADATA_DISABLED', 'false').downcase == 'true')
|
|
168
240
|
InstanceProfileCredentials.new(options.merge(profile: profile_name))
|
|
169
241
|
end
|
|
170
242
|
end
|
|
@@ -174,10 +246,14 @@ module Aws
|
|
|
174
246
|
profile: profile_name,
|
|
175
247
|
chain_config: @config
|
|
176
248
|
}
|
|
177
|
-
if options[:config]
|
|
249
|
+
if options[:config]&.region
|
|
178
250
|
assume_opts[:region] = options[:config].region
|
|
179
251
|
end
|
|
180
252
|
Aws.shared_config.assume_role_credentials_from_config(assume_opts)
|
|
181
253
|
end
|
|
254
|
+
|
|
255
|
+
def with_metrics(metrics, &block)
|
|
256
|
+
Aws::Plugins::UserAgent.metric(*metrics, &block)
|
|
257
|
+
end
|
|
182
258
|
end
|
|
183
259
|
end
|
|
@@ -6,21 +6,34 @@ module Aws
|
|
|
6
6
|
# @param [String] access_key_id
|
|
7
7
|
# @param [String] secret_access_key
|
|
8
8
|
# @param [String] session_token (nil)
|
|
9
|
-
|
|
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]
|
|
17
|
+
@metrics = ['CREDENTIALS_CODE']
|
|
13
18
|
end
|
|
14
19
|
|
|
15
|
-
# @return [String
|
|
20
|
+
# @return [String]
|
|
16
21
|
attr_reader :access_key_id
|
|
17
22
|
|
|
18
|
-
# @return [String
|
|
23
|
+
# @return [String]
|
|
19
24
|
attr_reader :secret_access_key
|
|
20
25
|
|
|
21
26
|
# @return [String, nil]
|
|
22
27
|
attr_reader :session_token
|
|
23
28
|
|
|
29
|
+
# @return [String, nil]
|
|
30
|
+
attr_reader :account_id
|
|
31
|
+
|
|
32
|
+
# @api private
|
|
33
|
+
# Returns the credentials source. Used for tracking credentials
|
|
34
|
+
# related UserAgent metrics.
|
|
35
|
+
attr_accessor :metrics
|
|
36
|
+
|
|
24
37
|
# @return [Credentials]
|
|
25
38
|
def credentials
|
|
26
39
|
self
|
|
@@ -30,9 +43,9 @@ module Aws
|
|
|
30
43
|
# access key are both set.
|
|
31
44
|
def set?
|
|
32
45
|
!access_key_id.nil? &&
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
46
|
+
!access_key_id.empty? &&
|
|
47
|
+
!secret_access_key.nil? &&
|
|
48
|
+
!secret_access_key.empty?
|
|
36
49
|
end
|
|
37
50
|
|
|
38
51
|
# Removing the secret access key from the default inspect string.
|
|
@@ -183,7 +183,7 @@ module Aws
|
|
|
183
183
|
|
|
184
184
|
def open_connection
|
|
185
185
|
uri = URI.parse(@endpoint)
|
|
186
|
-
http = Net::HTTP.new(uri.hostname || @endpoint,
|
|
186
|
+
http = Net::HTTP.new(uri.hostname || @endpoint, uri.port || @port)
|
|
187
187
|
http.open_timeout = @http_open_timeout
|
|
188
188
|
http.read_timeout = @http_read_timeout
|
|
189
189
|
http.set_debug_output(@http_debug_output) if @http_debug_output
|
|
@@ -6,7 +6,7 @@ require 'resolv'
|
|
|
6
6
|
|
|
7
7
|
module Aws
|
|
8
8
|
# An auto-refreshing credential provider that loads credentials from
|
|
9
|
-
# instances running in
|
|
9
|
+
# instances running in containers.
|
|
10
10
|
#
|
|
11
11
|
# ecs_credentials = Aws::ECSCredentials.new(retries: 3)
|
|
12
12
|
# ec2 = Aws::EC2::Client.new(credentials: ecs_credentials)
|
|
@@ -15,7 +15,23 @@ module Aws
|
|
|
15
15
|
include RefreshingCredentials
|
|
16
16
|
|
|
17
17
|
# @api private
|
|
18
|
-
class Non200Response < RuntimeError
|
|
18
|
+
class Non200Response < RuntimeError
|
|
19
|
+
attr_reader :status_code, :body
|
|
20
|
+
|
|
21
|
+
def initialize(status_code, body = nil)
|
|
22
|
+
@status_code = status_code
|
|
23
|
+
@body = body
|
|
24
|
+
msg = "HTTP #{status_code}"
|
|
25
|
+
msg += ": #{body}" if body && !body.empty?
|
|
26
|
+
super(msg)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Raised when the token file cannot be read.
|
|
31
|
+
class TokenFileReadError < RuntimeError; end
|
|
32
|
+
|
|
33
|
+
# Raised when the token file is invalid.
|
|
34
|
+
class InvalidTokenError < RuntimeError; end
|
|
19
35
|
|
|
20
36
|
# These are the errors we trap when attempting to talk to the
|
|
21
37
|
# instance metadata service. Any of these imply the service
|
|
@@ -36,26 +52,26 @@ module Aws
|
|
|
36
52
|
# @option options [Integer] :retries (5) Number of times to retry
|
|
37
53
|
# when retrieving credentials.
|
|
38
54
|
# @option options [String] :ip_address ('169.254.170.2') This value is
|
|
39
|
-
# ignored if
|
|
40
|
-
# @option options [Integer] :port (80) This value is ignored if
|
|
41
|
-
# is set and
|
|
55
|
+
# ignored if `:endpoint` is set and `:credential_path` is not set.
|
|
56
|
+
# @option options [Integer] :port (80) This value is ignored if `:endpoint`
|
|
57
|
+
# is set and `:credential_path` is not set.
|
|
42
58
|
# @option options [String] :credential_path By default, the value of the
|
|
43
|
-
# AWS_CONTAINER_CREDENTIALS_RELATIVE_URI environment variable.
|
|
44
|
-
# @option options [String] :endpoint The
|
|
45
|
-
# By default, this is the value of the AWS_CONTAINER_CREDENTIALS_FULL_URI
|
|
46
|
-
# environment variable. This value is ignored if
|
|
47
|
-
# ENV['AWS_CONTAINER_CREDENTIALS_RELATIVE_URI'] is set.
|
|
59
|
+
# `AWS_CONTAINER_CREDENTIALS_RELATIVE_URI` environment variable.
|
|
60
|
+
# @option options [String] :endpoint The container credential endpoint.
|
|
61
|
+
# By default, this is the value of the `AWS_CONTAINER_CREDENTIALS_FULL_URI`
|
|
62
|
+
# environment variable. This value is ignored if `:credential_path` or
|
|
63
|
+
# `ENV['AWS_CONTAINER_CREDENTIALS_RELATIVE_URI']` is set.
|
|
48
64
|
# @option options [Float] :http_open_timeout (5)
|
|
49
65
|
# @option options [Float] :http_read_timeout (5)
|
|
50
|
-
# @option options [
|
|
66
|
+
# @option options [IO] :http_debug_output (nil) HTTP wire
|
|
67
|
+
# traces are sent to this object. You can specify something
|
|
68
|
+
# like `$stdout`.
|
|
69
|
+
# @option options [Numeric, Proc] :backoff By default, failures are retried
|
|
51
70
|
# with exponential back-off, i.e. `sleep(1.2 ** num_failures)`. You can
|
|
52
71
|
# pass a number of seconds to sleep between failed attempts, or
|
|
53
72
|
# a Proc that accepts the number of failures.
|
|
54
|
-
# @option options [
|
|
55
|
-
#
|
|
56
|
-
# like $stdout.
|
|
57
|
-
# @option options [Callable] before_refresh Proc called before
|
|
58
|
-
# credentials are refreshed. `before_refresh` is called
|
|
73
|
+
# @option options [Proc] :before_refresh A Proc called before
|
|
74
|
+
# credentials are refreshed. `:before_refresh` is called
|
|
59
75
|
# with an instance of this object when
|
|
60
76
|
# AWS credentials are required and need to be refreshed.
|
|
61
77
|
def initialize(options = {})
|
|
@@ -64,7 +80,6 @@ module Aws
|
|
|
64
80
|
endpoint = options[:endpoint] ||
|
|
65
81
|
ENV['AWS_CONTAINER_CREDENTIALS_FULL_URI']
|
|
66
82
|
initialize_uri(options, credential_path, endpoint)
|
|
67
|
-
@authorization_token = ENV['AWS_CONTAINER_AUTHORIZATION_TOKEN']
|
|
68
83
|
|
|
69
84
|
@retries = options[:retries] || 5
|
|
70
85
|
@http_open_timeout = options[:http_open_timeout] || 5
|
|
@@ -72,6 +87,7 @@ module Aws
|
|
|
72
87
|
@http_debug_output = options[:http_debug_output]
|
|
73
88
|
@backoff = backoff(options[:backoff])
|
|
74
89
|
@async_refresh = false
|
|
90
|
+
@metrics = ['CREDENTIALS_HTTP']
|
|
75
91
|
super
|
|
76
92
|
end
|
|
77
93
|
|
|
@@ -103,11 +119,18 @@ module Aws
|
|
|
103
119
|
|
|
104
120
|
def initialize_full_uri(endpoint)
|
|
105
121
|
uri = URI.parse(endpoint)
|
|
122
|
+
validate_full_uri_scheme!(uri)
|
|
106
123
|
validate_full_uri!(uri)
|
|
107
|
-
@host = uri.
|
|
124
|
+
@host = uri.hostname
|
|
108
125
|
@port = uri.port
|
|
109
126
|
@scheme = uri.scheme
|
|
110
|
-
@credential_path = uri.
|
|
127
|
+
@credential_path = uri.request_uri
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def validate_full_uri_scheme!(full_uri)
|
|
131
|
+
return if full_uri.is_a?(URI::HTTP) || full_uri.is_a?(URI::HTTPS)
|
|
132
|
+
|
|
133
|
+
raise ArgumentError, "'#{full_uri}' must be a valid HTTP or HTTPS URI"
|
|
111
134
|
end
|
|
112
135
|
|
|
113
136
|
# Validate that the full URI is using a loopback address if scheme is http.
|
|
@@ -115,19 +138,24 @@ module Aws
|
|
|
115
138
|
return unless full_uri.scheme == 'http'
|
|
116
139
|
|
|
117
140
|
begin
|
|
118
|
-
return if
|
|
141
|
+
return if valid_ip_address?(IPAddr.new(full_uri.host))
|
|
119
142
|
rescue IPAddr::InvalidAddressError
|
|
120
143
|
addresses = Resolv.getaddresses(full_uri.host)
|
|
121
|
-
return if addresses.all? { |addr|
|
|
144
|
+
return if addresses.all? { |addr| valid_ip_address?(IPAddr.new(addr)) }
|
|
122
145
|
end
|
|
123
146
|
|
|
124
147
|
raise ArgumentError,
|
|
125
|
-
'AWS_CONTAINER_CREDENTIALS_FULL_URI must use a loopback '\
|
|
126
|
-
'address when using the http scheme.'
|
|
148
|
+
'AWS_CONTAINER_CREDENTIALS_FULL_URI must use a local loopback '\
|
|
149
|
+
'or an ECS or EKS link-local address when using the http scheme.'
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def valid_ip_address?(ip_address)
|
|
153
|
+
ip_loopback?(ip_address) || ecs_or_eks_ip?(ip_address)
|
|
127
154
|
end
|
|
128
155
|
|
|
129
156
|
# loopback? method is available in Ruby 2.5+
|
|
130
157
|
# Replicate the logic here.
|
|
158
|
+
# loopback (IPv4 127.0.0.0/8, IPv6 ::1/128)
|
|
131
159
|
def ip_loopback?(ip_address)
|
|
132
160
|
case ip_address.family
|
|
133
161
|
when Socket::AF_INET
|
|
@@ -139,6 +167,20 @@ module Aws
|
|
|
139
167
|
end
|
|
140
168
|
end
|
|
141
169
|
|
|
170
|
+
# Verify that the IP address is a link-local address from ECS or EKS.
|
|
171
|
+
# ECS container host (IPv4 `169.254.170.2`)
|
|
172
|
+
# EKS container host (IPv4 `169.254.170.23`, IPv6 `fd00:ec2::23`)
|
|
173
|
+
def ecs_or_eks_ip?(ip_address)
|
|
174
|
+
case ip_address.family
|
|
175
|
+
when Socket::AF_INET
|
|
176
|
+
[0xa9feaa02, 0xa9feaa17].include?(ip_address)
|
|
177
|
+
when Socket::AF_INET6
|
|
178
|
+
ip_address == 0xfd00_0ec2_0000_0000_0000_0000_0000_0023
|
|
179
|
+
else
|
|
180
|
+
false
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
|
|
142
184
|
def backoff(backoff)
|
|
143
185
|
case backoff
|
|
144
186
|
when Proc then backoff
|
|
@@ -174,10 +216,37 @@ module Aws
|
|
|
174
216
|
http_get(conn, @credential_path)
|
|
175
217
|
end
|
|
176
218
|
end
|
|
177
|
-
rescue
|
|
219
|
+
rescue TokenFileReadError, InvalidTokenError
|
|
220
|
+
raise
|
|
221
|
+
rescue StandardError => e
|
|
222
|
+
warn("Error retrieving ECS Credentials: #{e.message}")
|
|
178
223
|
'{}'
|
|
179
224
|
end
|
|
180
225
|
|
|
226
|
+
def fetch_authorization_token
|
|
227
|
+
if (path = ENV['AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE'])
|
|
228
|
+
fetch_authorization_token_file(path)
|
|
229
|
+
elsif (token = ENV['AWS_CONTAINER_AUTHORIZATION_TOKEN'])
|
|
230
|
+
token
|
|
231
|
+
end
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
def fetch_authorization_token_file(path)
|
|
235
|
+
File.read(path).strip
|
|
236
|
+
rescue Errno::ENOENT
|
|
237
|
+
raise TokenFileReadError,
|
|
238
|
+
'AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE is set '\
|
|
239
|
+
"but the file doesn't exist: #{path}"
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
def validate_authorization_token!(token)
|
|
243
|
+
return unless token.include?("\r\n")
|
|
244
|
+
|
|
245
|
+
raise InvalidTokenError,
|
|
246
|
+
'Invalid Authorization token: token contains '\
|
|
247
|
+
'a newline and carriage return character.'
|
|
248
|
+
end
|
|
249
|
+
|
|
181
250
|
def open_connection
|
|
182
251
|
http = Net::HTTP.new(@host, @port, nil)
|
|
183
252
|
http.open_timeout = @http_open_timeout
|
|
@@ -190,18 +259,27 @@ module Aws
|
|
|
190
259
|
|
|
191
260
|
def http_get(connection, path)
|
|
192
261
|
request = Net::HTTP::Get.new(path)
|
|
193
|
-
request
|
|
262
|
+
set_authorization_token(request)
|
|
194
263
|
response = connection.request(request)
|
|
195
|
-
raise Non200Response unless response.code.to_i == 200
|
|
264
|
+
raise Non200Response.new(response.code.to_i, response.body) unless response.code.to_i == 200
|
|
196
265
|
|
|
197
266
|
response.body
|
|
198
267
|
end
|
|
199
268
|
|
|
269
|
+
def set_authorization_token(request)
|
|
270
|
+
if (authorization_token = fetch_authorization_token)
|
|
271
|
+
validate_authorization_token!(authorization_token)
|
|
272
|
+
request['Authorization'] = authorization_token
|
|
273
|
+
end
|
|
274
|
+
end
|
|
275
|
+
|
|
200
276
|
def retry_errors(error_classes, options = {})
|
|
201
277
|
max_retries = options[:max_retries]
|
|
202
278
|
retries = 0
|
|
203
279
|
begin
|
|
204
280
|
yield
|
|
281
|
+
rescue TokenFileReadError, InvalidTokenError
|
|
282
|
+
raise
|
|
205
283
|
rescue *error_classes => _e
|
|
206
284
|
raise unless retries < max_retries
|
|
207
285
|
|
|
@@ -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
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require "cgi/escape"
|
|
4
|
+
require "cgi/util" if RUBY_VERSION < "3.5"
|
|
4
5
|
|
|
5
6
|
module Aws
|
|
6
7
|
module Endpoints
|
|
@@ -28,7 +29,11 @@ module Aws
|
|
|
28
29
|
|
|
29
30
|
val = if (index = parts.first[BRACKET_REGEX, 1])
|
|
30
31
|
# remove brackets and index from part before indexing
|
|
31
|
-
|
|
32
|
+
if (base = parts.first.gsub(BRACKET_REGEX, '')) && !base.empty?
|
|
33
|
+
value[base][index.to_i]
|
|
34
|
+
else
|
|
35
|
+
value[index.to_i]
|
|
36
|
+
end
|
|
32
37
|
else
|
|
33
38
|
value[parts.first]
|
|
34
39
|
end
|
|
@@ -79,25 +84,18 @@ module Aws
|
|
|
79
84
|
return false if value.empty?
|
|
80
85
|
|
|
81
86
|
if allow_sub_domains
|
|
82
|
-
labels = value.split('.')
|
|
87
|
+
labels = value.split('.', -1)
|
|
83
88
|
return labels.all? { |l| valid_host_label?(l) }
|
|
84
89
|
end
|
|
85
90
|
|
|
86
|
-
value =~ /\A(?!-)[a-zA-Z0-9-]{1,63}(?<!-)\z/
|
|
91
|
+
!!(value =~ /\A(?!-)[a-zA-Z0-9-]{1,63}(?<!-)\z/)
|
|
87
92
|
end
|
|
88
93
|
|
|
89
94
|
# AWS
|
|
90
95
|
|
|
91
96
|
# aws.partition(value: string) Option<Partition>
|
|
92
97
|
def self.aws_partition(value)
|
|
93
|
-
partition
|
|
94
|
-
Aws::Partitions.find { |p| p.region?(value) } ||
|
|
95
|
-
Aws::Partitions.find { |p| value.match(p.region_regex) } ||
|
|
96
|
-
Aws::Partitions.find { |p| p.name == 'aws' }
|
|
97
|
-
|
|
98
|
-
return nil unless partition
|
|
99
|
-
|
|
100
|
-
partition.metadata
|
|
98
|
+
Aws::Partitions::Metadata.partition(value)
|
|
101
99
|
end
|
|
102
100
|
|
|
103
101
|
# aws.parseArn(value: string) Option<ARN>
|
|
@@ -114,13 +112,17 @@ module Aws
|
|
|
114
112
|
|
|
115
113
|
# aws.isVirtualHostableS3Bucket(value: string, allowSubDomains: bool) bool
|
|
116
114
|
def self.aws_virtual_hostable_s3_bucket?(value, allow_sub_domains = false)
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
115
|
+
return false if value.empty?
|
|
116
|
+
|
|
117
|
+
if allow_sub_domains
|
|
118
|
+
labels = value.split('.', -1)
|
|
119
|
+
return labels.all? { |l| aws_virtual_hostable_s3_bucket?(l) }
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# must be between 3 and 63 characters long, no uppercase
|
|
123
|
+
value =~ /\A(?!-)[a-z0-9-]{3,63}(?<!-)\z/ &&
|
|
124
|
+
# not an IP address
|
|
125
|
+
value !~ /(\d+\.){3}\d+/
|
|
124
126
|
end
|
|
125
127
|
end
|
|
126
128
|
end
|