aws-sdk-core 3.117.0 → 3.197.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +836 -0
- data/VERSION +1 -1
- data/lib/aws-defaults/default_configuration.rb +153 -0
- data/lib/aws-defaults/defaults_mode_config_resolver.rb +107 -0
- data/lib/aws-defaults.rb +3 -0
- data/lib/aws-sdk-core/arn.rb +13 -0
- data/lib/aws-sdk-core/assume_role_credentials.rb +21 -7
- data/lib/aws-sdk-core/assume_role_web_identity_credentials.rb +14 -10
- data/lib/aws-sdk-core/binary/decode_handler.rb +0 -5
- data/lib/aws-sdk-core/binary/encode_handler.rb +12 -1
- data/lib/aws-sdk-core/binary/event_builder.rb +34 -37
- data/lib/aws-sdk-core/client_stubs.rb +20 -13
- data/lib/aws-sdk-core/credential_provider.rb +4 -1
- data/lib/aws-sdk-core/credential_provider_chain.rb +8 -5
- data/lib/aws-sdk-core/ec2_metadata.rb +4 -3
- data/lib/aws-sdk-core/ecs_credentials.rb +187 -52
- data/lib/aws-sdk-core/endpoints/condition.rb +41 -0
- data/lib/aws-sdk-core/endpoints/endpoint.rb +17 -0
- data/lib/aws-sdk-core/endpoints/endpoint_rule.rb +75 -0
- data/lib/aws-sdk-core/endpoints/error_rule.rb +42 -0
- data/lib/aws-sdk-core/endpoints/function.rb +80 -0
- data/lib/aws-sdk-core/endpoints/matchers.rb +135 -0
- data/lib/aws-sdk-core/endpoints/reference.rb +31 -0
- data/lib/aws-sdk-core/endpoints/rule.rb +25 -0
- data/lib/aws-sdk-core/endpoints/rule_set.rb +52 -0
- data/lib/aws-sdk-core/endpoints/rules_provider.rb +37 -0
- data/lib/aws-sdk-core/endpoints/templater.rb +58 -0
- data/lib/aws-sdk-core/endpoints/tree_rule.rb +45 -0
- data/lib/aws-sdk-core/endpoints/url.rb +60 -0
- data/lib/aws-sdk-core/endpoints.rb +78 -0
- data/lib/aws-sdk-core/errors.rb +17 -4
- data/lib/aws-sdk-core/event_emitter.rb +0 -16
- data/lib/aws-sdk-core/ini_parser.rb +7 -0
- data/lib/aws-sdk-core/instance_profile_credentials.rb +127 -33
- data/lib/aws-sdk-core/json/builder.rb +8 -1
- data/lib/aws-sdk-core/json/error_handler.rb +30 -4
- data/lib/aws-sdk-core/json/handler.rb +8 -1
- data/lib/aws-sdk-core/json/json_engine.rb +10 -8
- data/lib/aws-sdk-core/json/oj_engine.rb +33 -6
- data/lib/aws-sdk-core/json/parser.rb +38 -2
- data/lib/aws-sdk-core/json.rb +8 -26
- data/lib/aws-sdk-core/log/formatter.rb +6 -0
- data/lib/aws-sdk-core/log/param_filter.rb +9 -1
- data/lib/aws-sdk-core/lru_cache.rb +75 -0
- data/lib/aws-sdk-core/pageable_response.rb +81 -32
- data/lib/aws-sdk-core/param_validator.rb +36 -2
- data/lib/aws-sdk-core/plugins/bearer_authorization.rb +67 -0
- data/lib/aws-sdk-core/plugins/checksum_algorithm.rb +342 -0
- data/lib/aws-sdk-core/plugins/client_metrics_plugin.rb +1 -0
- data/lib/aws-sdk-core/plugins/client_metrics_send_plugin.rb +14 -2
- data/lib/aws-sdk-core/plugins/credentials_configuration.rb +29 -1
- data/lib/aws-sdk-core/plugins/defaults_mode.rb +40 -0
- data/lib/aws-sdk-core/plugins/endpoint_discovery.rb +6 -2
- data/lib/aws-sdk-core/plugins/http_checksum.rb +9 -1
- data/lib/aws-sdk-core/plugins/invocation_id.rb +1 -11
- data/lib/aws-sdk-core/plugins/jsonvalue_converter.rb +34 -6
- data/lib/aws-sdk-core/plugins/logging.rb +2 -0
- data/lib/aws-sdk-core/plugins/protocols/api_gateway.rb +17 -0
- data/lib/aws-sdk-core/plugins/protocols/rest_json.rb +4 -2
- data/lib/aws-sdk-core/plugins/protocols/rest_xml.rb +1 -2
- data/lib/aws-sdk-core/plugins/recursion_detection.rb +38 -0
- data/lib/aws-sdk-core/plugins/regional_endpoint.rb +144 -17
- data/lib/aws-sdk-core/plugins/request_compression.rb +226 -0
- data/lib/aws-sdk-core/plugins/response_paging.rb +1 -1
- data/lib/aws-sdk-core/plugins/retries/error_inspector.rb +7 -4
- data/lib/aws-sdk-core/plugins/retry_errors.rb +33 -7
- data/lib/aws-sdk-core/plugins/sign.rb +211 -0
- data/lib/aws-sdk-core/plugins/signature_v2.rb +1 -0
- data/lib/aws-sdk-core/plugins/signature_v4.rb +28 -31
- data/lib/aws-sdk-core/plugins/stub_responses.rb +6 -1
- data/lib/aws-sdk-core/plugins/user_agent.rb +152 -14
- data/lib/aws-sdk-core/process_credentials.rb +50 -34
- data/lib/aws-sdk-core/query/ec2_param_builder.rb +5 -7
- data/lib/aws-sdk-core/query/param_builder.rb +2 -2
- data/lib/aws-sdk-core/refreshing_credentials.rb +49 -18
- data/lib/aws-sdk-core/refreshing_token.rb +71 -0
- data/lib/aws-sdk-core/rest/handler.rb +1 -1
- data/lib/aws-sdk-core/rest/request/body.rb +49 -4
- data/lib/aws-sdk-core/rest/request/content_type.rb +60 -0
- data/lib/aws-sdk-core/rest/request/endpoint.rb +24 -4
- data/lib/aws-sdk-core/rest/request/headers.rb +23 -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 +10 -3
- data/lib/aws-sdk-core/rest.rb +1 -0
- data/lib/aws-sdk-core/shared_config.rb +112 -12
- data/lib/aws-sdk-core/sso_credentials.rb +92 -51
- data/lib/aws-sdk-core/sso_token_provider.rb +135 -0
- data/lib/aws-sdk-core/static_token_provider.rb +14 -0
- data/lib/aws-sdk-core/structure.rb +16 -5
- data/lib/aws-sdk-core/stubbing/stub_data.rb +11 -0
- data/lib/aws-sdk-core/token.rb +31 -0
- data/lib/aws-sdk-core/token_provider.rb +15 -0
- data/lib/aws-sdk-core/token_provider_chain.rb +51 -0
- data/lib/aws-sdk-core/util.rb +39 -0
- data/lib/aws-sdk-core/waiters/poller.rb +4 -2
- data/lib/aws-sdk-core/xml/builder.rb +17 -9
- data/lib/aws-sdk-core/xml/error_handler.rb +31 -8
- data/lib/aws-sdk-core/xml/parser/engines/oga.rb +2 -0
- data/lib/aws-sdk-core/xml/parser/engines/ox.rb +1 -1
- data/lib/aws-sdk-core/xml/parser/engines/rexml.rb +0 -8
- data/lib/aws-sdk-core/xml/parser/frame.rb +27 -20
- data/lib/aws-sdk-core/xml/parser/stack.rb +2 -0
- data/lib/aws-sdk-core.rb +21 -0
- data/lib/aws-sdk-sso/client.rb +157 -50
- data/lib/aws-sdk-sso/endpoint_parameters.rb +66 -0
- data/lib/aws-sdk-sso/endpoint_provider.rb +57 -0
- data/lib/aws-sdk-sso/endpoints.rb +72 -0
- data/lib/aws-sdk-sso/plugins/endpoints.rb +78 -0
- data/lib/aws-sdk-sso/types.rb +8 -43
- data/lib/aws-sdk-sso.rb +5 -1
- data/lib/aws-sdk-ssooidc/client.rb +1008 -0
- data/lib/aws-sdk-ssooidc/client_api.rb +293 -0
- data/lib/aws-sdk-ssooidc/customizations.rb +1 -0
- data/lib/aws-sdk-ssooidc/endpoint_parameters.rb +66 -0
- data/lib/aws-sdk-ssooidc/endpoint_provider.rb +57 -0
- data/lib/aws-sdk-ssooidc/endpoints.rb +72 -0
- data/lib/aws-sdk-ssooidc/errors.rb +342 -0
- data/lib/aws-sdk-ssooidc/plugins/endpoints.rb +78 -0
- data/lib/aws-sdk-ssooidc/resource.rb +26 -0
- data/lib/aws-sdk-ssooidc/types.rb +823 -0
- data/lib/aws-sdk-ssooidc.rb +59 -0
- data/lib/aws-sdk-sts/client.rb +472 -398
- data/lib/aws-sdk-sts/client_api.rb +20 -9
- data/lib/aws-sdk-sts/endpoint_parameters.rb +78 -0
- data/lib/aws-sdk-sts/endpoint_provider.rb +112 -0
- data/lib/aws-sdk-sts/endpoints.rb +136 -0
- data/lib/aws-sdk-sts/plugins/endpoints.rb +86 -0
- data/lib/aws-sdk-sts/plugins/sts_regional_endpoints.rb +5 -1
- data/lib/aws-sdk-sts/presigner.rb +14 -10
- data/lib/aws-sdk-sts/types.rb +168 -227
- data/lib/aws-sdk-sts.rb +5 -1
- data/lib/seahorse/client/async_base.rb +1 -2
- data/lib/seahorse/client/async_response.rb +19 -0
- data/lib/seahorse/client/base.rb +1 -0
- data/lib/seahorse/client/configuration.rb +5 -5
- data/lib/seahorse/client/h2/connection.rb +15 -16
- data/lib/seahorse/client/h2/handler.rb +5 -5
- data/lib/seahorse/client/net_http/connection_pool.rb +10 -9
- data/lib/seahorse/client/net_http/handler.rb +15 -7
- data/lib/seahorse/client/net_http/patches.rb +12 -86
- data/lib/seahorse/client/plugin.rb +9 -0
- data/lib/seahorse/client/plugins/content_length.rb +11 -5
- data/lib/seahorse/client/plugins/h2.rb +3 -3
- data/lib/seahorse/client/plugins/net_http.rb +73 -10
- data/lib/seahorse/client/plugins/request_callback.rb +40 -9
- data/lib/seahorse/client/response.rb +6 -0
- data/lib/seahorse/model/operation.rb +6 -0
- data/lib/seahorse/model/shapes.rb +27 -2
- data/lib/seahorse/util.rb +4 -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/waiters/errors.rbs +20 -0
- data/sig/aws-sdk-core.rbs +7 -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 +82 -17
- data/lib/aws-sdk-sso/plugins/content_type.rb +0 -25
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.197.2
|
@@ -0,0 +1,153 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'defaults_mode_config_resolver'
|
4
|
+
|
5
|
+
module Aws
|
6
|
+
|
7
|
+
# A defaults mode determines how certain default configuration options are resolved in the SDK.
|
8
|
+
#
|
9
|
+
# *Note*: For any mode other than `'legacy'` the vended default values might change as best practices may
|
10
|
+
# evolve. As a result, it is encouraged to perform testing when upgrading the SDK if you are using a mode other than
|
11
|
+
# `'legacy'`. While the `'legacy'` defaults mode is specific to Ruby,
|
12
|
+
# other modes are standardized across all of the AWS SDKs.
|
13
|
+
#
|
14
|
+
# The defaults mode can be configured:
|
15
|
+
#
|
16
|
+
# * Directly on a client via `:defaults_mode`
|
17
|
+
#
|
18
|
+
# * On a configuration profile via the "defaults_mode" profile file property.
|
19
|
+
#
|
20
|
+
# * Globally via the "AWS_DEFAULTS_MODE" environment variable.
|
21
|
+
#
|
22
|
+
#
|
23
|
+
# #defaults START - documentation
|
24
|
+
# The following `:default_mode` values are supported:
|
25
|
+
#
|
26
|
+
# * `'standard'` -
|
27
|
+
# The STANDARD mode provides the latest recommended default values
|
28
|
+
# that should be safe to run in most scenarios
|
29
|
+
#
|
30
|
+
# Note that the default values vended from this mode might change as
|
31
|
+
# best practices may evolve. As a result, it is encouraged to perform
|
32
|
+
# tests when upgrading the SDK
|
33
|
+
#
|
34
|
+
# * `'in-region'` -
|
35
|
+
# The IN\_REGION mode builds on the standard mode and includes
|
36
|
+
# optimization tailored for applications which call AWS services from
|
37
|
+
# within the same AWS region
|
38
|
+
#
|
39
|
+
# Note that the default values vended from this mode might change as
|
40
|
+
# best practices may evolve. As a result, it is encouraged to perform
|
41
|
+
# tests when upgrading the SDK
|
42
|
+
#
|
43
|
+
# * `'cross-region'` -
|
44
|
+
# The CROSS\_REGION mode builds on the standard mode and includes
|
45
|
+
# optimization tailored for applications which call AWS services in a
|
46
|
+
# different region
|
47
|
+
#
|
48
|
+
# Note that the default values vended from this mode might change as
|
49
|
+
# best practices may evolve. As a result, it is encouraged to perform
|
50
|
+
# tests when upgrading the SDK
|
51
|
+
#
|
52
|
+
# * `'mobile'` -
|
53
|
+
# The MOBILE mode builds on the standard mode and includes
|
54
|
+
# optimization tailored for mobile applications
|
55
|
+
#
|
56
|
+
# Note that the default values vended from this mode might change as
|
57
|
+
# best practices may evolve. As a result, it is encouraged to perform
|
58
|
+
# tests when upgrading the SDK
|
59
|
+
#
|
60
|
+
# * `'auto'` -
|
61
|
+
# The AUTO mode is an experimental mode that builds on the standard
|
62
|
+
# mode. The SDK will attempt to discover the execution environment to
|
63
|
+
# determine the appropriate settings automatically.
|
64
|
+
#
|
65
|
+
# Note that the auto detection is heuristics-based and does not
|
66
|
+
# guarantee 100% accuracy. STANDARD mode will be used if the execution
|
67
|
+
# environment cannot be determined. The auto detection might query
|
68
|
+
# [EC2 Instance Metadata service][1], which might introduce latency.
|
69
|
+
# Therefore we recommend choosing an explicit defaults\_mode instead
|
70
|
+
# if startup latency is critical to your application
|
71
|
+
#
|
72
|
+
# * `'legacy'` -
|
73
|
+
# The LEGACY mode provides default settings that vary per SDK and were
|
74
|
+
# used prior to establishment of defaults\_mode
|
75
|
+
#
|
76
|
+
# Based on the provided mode, the SDK will vend sensible default values
|
77
|
+
# tailored to the mode for the following settings:
|
78
|
+
#
|
79
|
+
# * `:retry_mode` -
|
80
|
+
# A retry mode specifies how the SDK attempts retries. See [Retry
|
81
|
+
# Mode][2]
|
82
|
+
#
|
83
|
+
# * `:sts_regional_endpoints` -
|
84
|
+
# Specifies how the SDK determines the AWS service endpoint that it
|
85
|
+
# uses to talk to the AWS Security Token Service (AWS STS). See
|
86
|
+
# [Setting STS Regional endpoints][3]
|
87
|
+
#
|
88
|
+
# * `:s3_us_east_1_regional_endpoint` -
|
89
|
+
# Specifies how the SDK determines the AWS service endpoint that it
|
90
|
+
# uses to talk to the Amazon S3 for the us-east-1 region
|
91
|
+
#
|
92
|
+
# * `:http_open_timeout` -
|
93
|
+
# The amount of time after making an initial connection attempt on a
|
94
|
+
# socket, where if the client does not receive a completion of the
|
95
|
+
# connect handshake, the client gives up and fails the operation
|
96
|
+
#
|
97
|
+
# * `:ssl_timeout` -
|
98
|
+
# The maximum amount of time that a TLS handshake is allowed to take
|
99
|
+
# from the time the CLIENT HELLO message is sent to ethe time the
|
100
|
+
# client and server have fully negotiated ciphers and exchanged keys
|
101
|
+
#
|
102
|
+
# All options above can be configured by users, and the overridden value will take precedence.
|
103
|
+
#
|
104
|
+
# [1]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html
|
105
|
+
# [2]: https://docs.aws.amazon.com/sdkref/latest/guide/setting-global-retry_mode.html
|
106
|
+
# [3]: https://docs.aws.amazon.com/sdkref/latest/guide/setting-global-sts_regional_endpoints.html
|
107
|
+
#
|
108
|
+
# #defaults END - documentation
|
109
|
+
module DefaultsModeConfiguration
|
110
|
+
# @api private
|
111
|
+
# #defaults START - configuration
|
112
|
+
SDK_DEFAULT_CONFIGURATION =
|
113
|
+
{
|
114
|
+
"version" => 1,
|
115
|
+
"base" => {
|
116
|
+
"retryMode" => "standard",
|
117
|
+
"stsRegionalEndpoints" => "regional",
|
118
|
+
"s3UsEast1RegionalEndpoints" => "regional",
|
119
|
+
"connectTimeoutInMillis" => 1100,
|
120
|
+
"tlsNegotiationTimeoutInMillis" => 1100
|
121
|
+
},
|
122
|
+
"modes" => {
|
123
|
+
"standard" => {
|
124
|
+
"connectTimeoutInMillis" => {
|
125
|
+
"override" => 3100
|
126
|
+
},
|
127
|
+
"tlsNegotiationTimeoutInMillis" => {
|
128
|
+
"override" => 3100
|
129
|
+
}
|
130
|
+
},
|
131
|
+
"in-region" => {
|
132
|
+
},
|
133
|
+
"cross-region" => {
|
134
|
+
"connectTimeoutInMillis" => {
|
135
|
+
"override" => 3100
|
136
|
+
},
|
137
|
+
"tlsNegotiationTimeoutInMillis" => {
|
138
|
+
"override" => 3100
|
139
|
+
}
|
140
|
+
},
|
141
|
+
"mobile" => {
|
142
|
+
"connectTimeoutInMillis" => {
|
143
|
+
"override" => 30000
|
144
|
+
},
|
145
|
+
"tlsNegotiationTimeoutInMillis" => {
|
146
|
+
"override" => 30000
|
147
|
+
}
|
148
|
+
}
|
149
|
+
}
|
150
|
+
}
|
151
|
+
# #defaults END - configuration
|
152
|
+
end
|
153
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Aws
|
4
|
+
#@api private
|
5
|
+
class DefaultsModeConfigResolver
|
6
|
+
|
7
|
+
@@application_region = nil
|
8
|
+
@@application_region_mutex = Mutex.new
|
9
|
+
@@imds_client = EC2Metadata.new(retries: 0, http_open_timeout: 0.01)
|
10
|
+
|
11
|
+
# mappings from Ruby SDK configuration names to the
|
12
|
+
# sdk defaults option names and (optional) scale modifiers
|
13
|
+
CFG_OPTIONS = {
|
14
|
+
retry_mode: { name: "retryMode" },
|
15
|
+
sts_regional_endpoints: { name: "stsRegionalEndpoints" },
|
16
|
+
s3_us_east_1_regional_endpoint: { name: "s3UsEast1RegionalEndpoints" },
|
17
|
+
http_open_timeout: { name: "connectTimeoutInMillis", scale: 0.001 },
|
18
|
+
http_read_timeout: { name: "timeToFirstByteTimeoutInMillis", scale: 0.001 },
|
19
|
+
ssl_timeout: { name: "tlsNegotiationTimeoutInMillis", scale: 0.001 }
|
20
|
+
}.freeze
|
21
|
+
|
22
|
+
def initialize(sdk_defaults, cfg)
|
23
|
+
@sdk_defaults = sdk_defaults
|
24
|
+
@cfg = cfg
|
25
|
+
@resolved_mode = nil
|
26
|
+
@mutex = Mutex.new
|
27
|
+
end
|
28
|
+
|
29
|
+
# option_name should be the symbolized ruby name to resolve
|
30
|
+
# returns the ruby appropriate value or nil if none are resolved
|
31
|
+
def resolve(option_name)
|
32
|
+
return unless (std_option = CFG_OPTIONS[option_name])
|
33
|
+
mode = resolved_mode.downcase
|
34
|
+
|
35
|
+
return nil if mode == 'legacy'
|
36
|
+
|
37
|
+
value = resolve_for_mode(std_option[:name], mode)
|
38
|
+
value = value * std_option[:scale] if value && std_option[:scale]
|
39
|
+
|
40
|
+
value
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
def resolved_mode
|
45
|
+
@mutex.synchronize do
|
46
|
+
return @resolved_mode unless @resolved_mode.nil?
|
47
|
+
|
48
|
+
@resolved_mode = @cfg.defaults_mode == 'auto' ? resolve_auto_mode : @cfg.defaults_mode
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def resolve_auto_mode
|
53
|
+
return "mobile" if env_mobile?
|
54
|
+
|
55
|
+
region = application_current_region
|
56
|
+
|
57
|
+
if region
|
58
|
+
@cfg.region == region ? "in-region": "cross-region"
|
59
|
+
else
|
60
|
+
# We don't seem to be mobile, and we couldn't determine whether we're running within an AWS region. Fall back to standard.
|
61
|
+
'standard'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def application_current_region
|
66
|
+
resolved_region = @@application_region_mutex.synchronize do
|
67
|
+
return @@application_region unless @@application_region.nil?
|
68
|
+
|
69
|
+
region = nil
|
70
|
+
if ENV['AWS_EXECUTION_ENV']
|
71
|
+
region = ENV['AWS_REGION'] || ENV['AWS_DEFAULT_REGION']
|
72
|
+
end
|
73
|
+
|
74
|
+
if region.nil? && ENV['AWS_EC2_METADATA_DISABLED']&.downcase != "true"
|
75
|
+
begin
|
76
|
+
region = @@imds_client.get('/latest/meta-data/placement/region')
|
77
|
+
rescue
|
78
|
+
# unable to get region, leave it unset
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# required so that we cache the unknown/nil result
|
83
|
+
@@application_region = region || :unknown
|
84
|
+
end
|
85
|
+
resolved_region == :unknown ? nil : resolved_region
|
86
|
+
end
|
87
|
+
|
88
|
+
def resolve_for_mode(name, mode)
|
89
|
+
base_value = @sdk_defaults['base'][name]
|
90
|
+
mode_value = @sdk_defaults['modes'].fetch(mode, {})[name]
|
91
|
+
|
92
|
+
if mode_value.nil?
|
93
|
+
return base_value
|
94
|
+
end
|
95
|
+
|
96
|
+
return mode_value['override'] unless mode_value['override'].nil?
|
97
|
+
return base_value + mode_value['add'] unless mode_value['add'].nil?
|
98
|
+
return base_value * mode_value['multiply'] unless mode_value['multiply'].nil?
|
99
|
+
return base_value
|
100
|
+
end
|
101
|
+
|
102
|
+
def env_mobile?
|
103
|
+
false
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
end
|
data/lib/aws-defaults.rb
ADDED
data/lib/aws-sdk-core/arn.rb
CHANGED
@@ -88,5 +88,18 @@ module Aws
|
|
88
88
|
resource: @resource
|
89
89
|
}
|
90
90
|
end
|
91
|
+
|
92
|
+
# Return the ARN as JSON
|
93
|
+
#
|
94
|
+
# @return [Hash]
|
95
|
+
def as_json(_options = nil)
|
96
|
+
{
|
97
|
+
'partition' => @partition,
|
98
|
+
'service' => @service,
|
99
|
+
'region' => @region,
|
100
|
+
'accountId' => @account_id,
|
101
|
+
'resource' => @resource
|
102
|
+
}
|
103
|
+
end
|
91
104
|
end
|
92
105
|
end
|
@@ -3,20 +3,20 @@
|
|
3
3
|
require 'set'
|
4
4
|
|
5
5
|
module Aws
|
6
|
-
|
7
|
-
#
|
8
|
-
# a role via {Aws::STS::Client#assume_role}.
|
6
|
+
# An auto-refreshing credential provider that assumes a role via
|
7
|
+
# {Aws::STS::Client#assume_role}.
|
9
8
|
#
|
10
9
|
# role_credentials = Aws::AssumeRoleCredentials.new(
|
11
10
|
# client: Aws::STS::Client.new(...),
|
12
11
|
# role_arn: "linked::account::arn",
|
13
12
|
# role_session_name: "session-name"
|
14
13
|
# )
|
15
|
-
#
|
16
14
|
# ec2 = Aws::EC2::Client.new(credentials: role_credentials)
|
17
15
|
#
|
18
|
-
# If you omit `:client` option, a new {STS::Client} object will be
|
19
|
-
# constructed.
|
16
|
+
# If you omit `:client` option, a new {Aws::STS::Client} object will be
|
17
|
+
# constructed with additional options that were provided.
|
18
|
+
#
|
19
|
+
# @see Aws::STS::Client#assume_role
|
20
20
|
class AssumeRoleCredentials
|
21
21
|
|
22
22
|
include CredentialProvider
|
@@ -28,23 +28,37 @@ module Aws
|
|
28
28
|
# @option options [Integer] :duration_seconds
|
29
29
|
# @option options [String] :external_id
|
30
30
|
# @option options [STS::Client] :client
|
31
|
+
# @option options [Callable] before_refresh Proc called before
|
32
|
+
# credentials are refreshed. Useful for updating tokens.
|
33
|
+
# `before_refresh` is called when AWS credentials are
|
34
|
+
# required and need to be refreshed. Tokens can be refreshed using
|
35
|
+
# the following example:
|
36
|
+
#
|
37
|
+
# before_refresh = Proc.new do |assume_role_credentials| do
|
38
|
+
# assume_role_credentials.assume_role_params['token_code'] = update_token
|
39
|
+
# end
|
40
|
+
#
|
31
41
|
def initialize(options = {})
|
32
42
|
client_opts = {}
|
33
43
|
@assume_role_params = {}
|
34
44
|
options.each_pair do |key, value|
|
35
45
|
if self.class.assume_role_options.include?(key)
|
36
46
|
@assume_role_params[key] = value
|
37
|
-
|
47
|
+
elsif !CLIENT_EXCLUDE_OPTIONS.include?(key)
|
38
48
|
client_opts[key] = value
|
39
49
|
end
|
40
50
|
end
|
41
51
|
@client = client_opts[:client] || STS::Client.new(client_opts)
|
52
|
+
@async_refresh = true
|
42
53
|
super
|
43
54
|
end
|
44
55
|
|
45
56
|
# @return [STS::Client]
|
46
57
|
attr_reader :client
|
47
58
|
|
59
|
+
# @return [Hash]
|
60
|
+
attr_reader :assume_role_params
|
61
|
+
|
48
62
|
private
|
49
63
|
|
50
64
|
def refresh
|
@@ -5,9 +5,8 @@ require 'securerandom'
|
|
5
5
|
require 'base64'
|
6
6
|
|
7
7
|
module Aws
|
8
|
-
|
9
|
-
#
|
10
|
-
# a role via {Aws::STS::Client#assume_role_with_web_identity}.
|
8
|
+
# An auto-refreshing credential provider that assumes a role via
|
9
|
+
# {Aws::STS::Client#assume_role_with_web_identity}.
|
11
10
|
#
|
12
11
|
# role_credentials = Aws::AssumeRoleWebIdentityCredentials.new(
|
13
12
|
# client: Aws::STS::Client.new(...),
|
@@ -16,12 +15,12 @@ module Aws
|
|
16
15
|
# role_session_name: "session-name"
|
17
16
|
# ...
|
18
17
|
# )
|
19
|
-
#
|
20
|
-
# @see Aws::STS::Client#assume_role_with_web_identity
|
18
|
+
# ec2 = Aws::EC2::Client.new(credentials: role_credentials)
|
21
19
|
#
|
20
|
+
# If you omit `:client` option, a new {Aws::STS::Client} object will be
|
21
|
+
# constructed with additional options that were provided.
|
22
22
|
#
|
23
|
-
#
|
24
|
-
# constructed.
|
23
|
+
# @see Aws::STS::Client#assume_role_with_web_identity
|
25
24
|
class AssumeRoleWebIdentityCredentials
|
26
25
|
|
27
26
|
include CredentialProvider
|
@@ -39,14 +38,20 @@ module Aws
|
|
39
38
|
# encoded UUID is generated as the session name
|
40
39
|
#
|
41
40
|
# @option options [STS::Client] :client
|
41
|
+
#
|
42
|
+
# @option options [Callable] before_refresh Proc called before
|
43
|
+
# credentials are refreshed. `before_refresh` is called
|
44
|
+
# with an instance of this object when
|
45
|
+
# AWS credentials are required and need to be refreshed.
|
42
46
|
def initialize(options = {})
|
43
47
|
client_opts = {}
|
44
48
|
@assume_role_web_identity_params = {}
|
45
49
|
@token_file = options.delete(:web_identity_token_file)
|
50
|
+
@async_refresh = true
|
46
51
|
options.each_pair do |key, value|
|
47
52
|
if self.class.assume_role_web_identity_options.include?(key)
|
48
53
|
@assume_role_web_identity_params[key] = value
|
49
|
-
|
54
|
+
elsif !CLIENT_EXCLUDE_OPTIONS.include?(key)
|
50
55
|
client_opts[key] = value
|
51
56
|
end
|
52
57
|
end
|
@@ -94,11 +99,10 @@ module Aws
|
|
94
99
|
# @api private
|
95
100
|
def assume_role_web_identity_options
|
96
101
|
@arwio ||= begin
|
97
|
-
input = STS::Client.api.operation(:assume_role_with_web_identity).input
|
102
|
+
input = Aws::STS::Client.api.operation(:assume_role_with_web_identity).input
|
98
103
|
Set.new(input.shape.member_names)
|
99
104
|
end
|
100
105
|
end
|
101
|
-
|
102
106
|
end
|
103
107
|
end
|
104
108
|
end
|
@@ -33,11 +33,6 @@ module Aws
|
|
33
33
|
context.operation.errors,
|
34
34
|
context.http_response.body,
|
35
35
|
output_handler)
|
36
|
-
if input_emitter = context[:input_event_emitter]
|
37
|
-
# #emit will be blocked until 200 success
|
38
|
-
# see Aws::EventEmitter#emit
|
39
|
-
input_emitter.signal_queue << "ready"
|
40
|
-
end
|
41
36
|
end
|
42
37
|
|
43
38
|
context.http_response.on_success(200) do
|
@@ -13,7 +13,7 @@ module Aws
|
|
13
13
|
context.config.api.metadata['protocol'],
|
14
14
|
eventstream_member,
|
15
15
|
context.operation.input,
|
16
|
-
context
|
16
|
+
signer_for(context)
|
17
17
|
)
|
18
18
|
context[:input_event_emitter] = input_es_handler.event_emitter
|
19
19
|
end
|
@@ -22,6 +22,17 @@ module Aws
|
|
22
22
|
|
23
23
|
private
|
24
24
|
|
25
|
+
def signer_for(context)
|
26
|
+
# New endpoint/signing logic, use the auth scheme to make a signer
|
27
|
+
if context[:auth_scheme]
|
28
|
+
Aws::Plugins::Sign.signer_for(context[:auth_scheme], context.config)
|
29
|
+
else
|
30
|
+
# Previous implementation always assumed sigv4_signer from config.
|
31
|
+
# Relies only on sigv4 signing (and plugin) for event stream services
|
32
|
+
context.config.sigv4_signer
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
25
36
|
def eventstream_input?(ctx)
|
26
37
|
ctx.operation.input.shape.members.each do |_, ref|
|
27
38
|
return ref if ref.eventstream
|
@@ -42,41 +42,39 @@ module Aws
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
#
|
46
|
-
if !explicit_payload && !implicit_payload_members.empty?
|
47
|
-
if implicit_payload_members.size > 1
|
48
|
-
payload_shape = Shapes::StructureShape.new
|
49
|
-
implicit_payload_members.each do |m_name, m_ref|
|
50
|
-
payload_shape.add_member(m_name, m_ref)
|
51
|
-
end
|
52
|
-
payload_ref = Shapes::ShapeRef.new(shape: payload_shape)
|
53
|
-
|
54
|
-
payload = build_payload_members(payload_ref, params)
|
55
|
-
else
|
56
|
-
m_name, m_ref = implicit_payload_members.first
|
57
|
-
streaming, content_type = _content_type(m_ref.shape)
|
58
|
-
|
59
|
-
es_headers[":content-type"] = Aws::EventStream::HeaderValue.new(
|
60
|
-
type: "string", value: content_type)
|
61
|
-
payload = _build_payload(streaming, m_ref, params[m_name])
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
|
45
|
+
# handle header members for all cases
|
66
46
|
event_ref.shape.members.each do |member_name, member_ref|
|
67
47
|
if member_ref.eventheader && params[member_name]
|
68
48
|
header_value = params[member_name]
|
69
49
|
es_headers[member_ref.shape.name] = Aws::EventStream::HeaderValue.new(
|
70
|
-
type:
|
50
|
+
type: header_value_type(member_ref.shape, header_value),
|
71
51
|
value: header_value
|
72
52
|
)
|
73
|
-
|
74
|
-
|
75
|
-
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# implict payload
|
57
|
+
if !explicit_payload && !implicit_payload_members.empty?
|
58
|
+
payload_shape = StructureShape.new
|
59
|
+
implicit_payload_members.each do |m_name, m_ref|
|
60
|
+
payload_shape.add_member(m_name, m_ref)
|
61
|
+
end
|
62
|
+
payload_ref = ShapeRef.new(shape: payload_shape)
|
76
63
|
|
77
|
-
|
78
|
-
|
79
|
-
|
64
|
+
payload = build_payload_members(payload_ref, params)
|
65
|
+
.force_encoding(Encoding::BINARY)
|
66
|
+
|
67
|
+
|
68
|
+
es_headers[":content-type"] = Aws::EventStream::HeaderValue.new(
|
69
|
+
type: "string", value: content_type(payload_ref.shape))
|
70
|
+
else
|
71
|
+
# explicit payload, serialize just the payload member
|
72
|
+
event_ref.shape.members.each do |member_name, member_ref|
|
73
|
+
if member_ref.eventpayload && params[member_name]
|
74
|
+
es_headers[":content-type"] = Aws::EventStream::HeaderValue.new(
|
75
|
+
type: "string", value: content_type(member_ref.shape))
|
76
|
+
payload = params[member_name]
|
77
|
+
end
|
80
78
|
end
|
81
79
|
end
|
82
80
|
|
@@ -86,15 +84,15 @@ module Aws
|
|
86
84
|
)
|
87
85
|
end
|
88
86
|
|
89
|
-
def
|
87
|
+
def content_type(shape)
|
90
88
|
case shape
|
91
|
-
when BlobShape then
|
92
|
-
when StringShape then
|
89
|
+
when BlobShape then "application/octet-stream"
|
90
|
+
when StringShape then "text/plain"
|
93
91
|
when StructureShape then
|
94
92
|
if @serializer_class.name.include?('Xml')
|
95
|
-
|
93
|
+
"text/xml"
|
96
94
|
elsif @serializer_class.name.include?('Json')
|
97
|
-
|
95
|
+
"application/json"
|
98
96
|
end
|
99
97
|
else
|
100
98
|
raise Aws::Errors::EventStreamBuilderError.new(
|
@@ -102,7 +100,7 @@ module Aws
|
|
102
100
|
end
|
103
101
|
end
|
104
102
|
|
105
|
-
def
|
103
|
+
def header_value_type(shape, value)
|
106
104
|
case shape
|
107
105
|
when StringShape then "string"
|
108
106
|
when IntegerShape then "integer"
|
@@ -115,10 +113,9 @@ module Aws
|
|
115
113
|
end
|
116
114
|
end
|
117
115
|
|
118
|
-
def
|
119
|
-
|
116
|
+
def build_payload_members(payload_ref, params)
|
117
|
+
@serializer_class.new(payload_ref).serialize(params)
|
120
118
|
end
|
121
|
-
|
122
119
|
end
|
123
120
|
end
|
124
121
|
end
|
@@ -24,15 +24,16 @@ module Aws
|
|
24
24
|
end
|
25
25
|
|
26
26
|
# When a client is stubbed allow the user to access the requests made
|
27
|
-
@api_requests = []
|
28
|
-
|
29
|
-
requests = @api_requests
|
27
|
+
requests = @api_requests = []
|
28
|
+
requests_mutex = @requests_mutex = Mutex.new
|
30
29
|
self.handle do |context|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
30
|
+
requests_mutex.synchronize do
|
31
|
+
requests << {
|
32
|
+
operation_name: context.operation_name,
|
33
|
+
params: context.params,
|
34
|
+
context: context
|
35
|
+
}
|
36
|
+
end
|
36
37
|
@handler.call(context)
|
37
38
|
end
|
38
39
|
end
|
@@ -194,10 +195,12 @@ module Aws
|
|
194
195
|
# is not stubbed.
|
195
196
|
def api_requests(options = {})
|
196
197
|
if config.stub_responses
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
198
|
+
@requests_mutex.synchronize do
|
199
|
+
if options[:exclude_presign]
|
200
|
+
@api_requests.reject {|req| req[:context][:presigned_url] }
|
201
|
+
else
|
202
|
+
@api_requests
|
203
|
+
end
|
201
204
|
end
|
202
205
|
else
|
203
206
|
msg = 'This method is only implemented for stubbed clients, and is '\
|
@@ -262,13 +265,17 @@ module Aws
|
|
262
265
|
end
|
263
266
|
|
264
267
|
def convert_stub(operation_name, stub)
|
265
|
-
case stub
|
268
|
+
stub = case stub
|
266
269
|
when Proc then stub
|
267
270
|
when Exception, Class then { error: stub }
|
268
271
|
when String then service_error_stub(stub)
|
269
272
|
when Hash then http_response_stub(operation_name, stub)
|
270
273
|
else { data: stub }
|
271
274
|
end
|
275
|
+
if Hash === stub
|
276
|
+
stub[:mutex] = Mutex.new
|
277
|
+
end
|
278
|
+
stub
|
272
279
|
end
|
273
280
|
|
274
281
|
def service_error_stub(error_code)
|
@@ -161,7 +161,8 @@ module Aws
|
|
161
161
|
|
162
162
|
def instance_profile_credentials(options)
|
163
163
|
profile_name = determine_profile_name(options)
|
164
|
-
if ENV['AWS_CONTAINER_CREDENTIALS_RELATIVE_URI']
|
164
|
+
if ENV['AWS_CONTAINER_CREDENTIALS_RELATIVE_URI'] ||
|
165
|
+
ENV['AWS_CONTAINER_CREDENTIALS_FULL_URI']
|
165
166
|
ECSCredentials.new(options)
|
166
167
|
else
|
167
168
|
InstanceProfileCredentials.new(options.merge(profile: profile_name))
|
@@ -169,12 +170,14 @@ module Aws
|
|
169
170
|
end
|
170
171
|
|
171
172
|
def assume_role_with_profile(options, profile_name)
|
172
|
-
|
173
|
-
Aws.shared_config.assume_role_credentials_from_config(
|
173
|
+
assume_opts = {
|
174
174
|
profile: profile_name,
|
175
|
-
region: region,
|
176
175
|
chain_config: @config
|
177
|
-
|
176
|
+
}
|
177
|
+
if options[:config] && options[:config].region
|
178
|
+
assume_opts[:region] = options[:config].region
|
179
|
+
end
|
180
|
+
Aws.shared_config.assume_role_credentials_from_config(assume_opts)
|
178
181
|
end
|
179
182
|
end
|
180
183
|
end
|