aws-sdk-core 3.113.1 → 3.118.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 22a9b79629fe96dba0c2ab281d0b976827e8681b72736c5344491b5988a2835f
4
- data.tar.gz: 556f267c1016e41cabd38213669d478c6b27291262e66dd6455c2fed5f087a61
3
+ metadata.gz: f880e91159fbbd13553271c925b06c11172de5ffda9f8931ae4ee66b09160100
4
+ data.tar.gz: 47f884e80449f6bffacc2babc3f96ba2248694aaab27da5bdbbaf895f29a0ec5
5
5
  SHA512:
6
- metadata.gz: bea46ccd2d82d78a1be079e887a4cb2721a50eca0e3111b8ed86e7f4ea45e1b35a2d0fdff80b99088b04a53c16e26c5fd7b4072e8ff75efb4509d129ff8ffc07
7
- data.tar.gz: bcae08d043d43dfdd0f31aa1e6b29cfd6b5eee9da2c00d6a2ddad56f93cb57bc33cd1f121b694528cab2498ade089c1b685bafab716fd40eec9612ca8ae9effe
6
+ metadata.gz: d776a66ce68988249850ffb707f23cabc7097232042dcb4425bdb1dc027a445d6adeacfb496758340cf66865cf2e5597c6d3ae67b48d81814b24d1d40ecdc6d9
7
+ data.tar.gz: afe710d79ca075dfa33da32ef42356f0ccc60362bb6b66d0aa76f5171141df24418288b48e3c12bb0fd40c8a650cee273177756a7993b4b44099f83f2b7c8253
data/CHANGELOG.md CHANGED
@@ -1,6 +1,49 @@
1
1
  Unreleased Changes
2
2
  ------------------
3
3
 
4
+ 3.118.0 (2021-07-28)
5
+ ------------------
6
+
7
+ * Feature - Add support for Tagged Unions using a "sealed" classes like approach where each union member has a corresponding subclass.
8
+
9
+ 3.117.0 (2021-07-12)
10
+ ------------------
11
+
12
+ * Feature - Support IPv6 endpoints for `Aws::InstanceProfileCredentials`. It supports two shared configuration options (`ec2_metadata_service_endpoint` & `ec2_metadata_service_endpoint_mode`), two ENV variables (`AWS_EC2_METADATA_SERVICE_ENDPOINT` & `AWS_EC2_METADATA_SERVICE_ENDPOINT_MODE`), and two constructor options (`:endpoint` & `:endpoint_mode`).
13
+
14
+ * Feature - Support IPv6 endpoint for `Aws::EC2Metadata` client. It can be configured with `:endpoint` or `:endpoint_mode`.
15
+
16
+ 3.116.0 (2021-07-07)
17
+ ------------------
18
+
19
+ * Feature - Updated Aws::STS::Client with the latest API changes.
20
+
21
+ 3.115.0 (2021-06-23)
22
+ ------------------
23
+
24
+ * Feature - Add support for Assume Role Chaining in profiles. (#2531)
25
+ * Issue - Fixed an issue with `Seahorse::Client::H2::Connection` for non-https endpoints. (#2542)
26
+
27
+ 3.114.3 (2021-06-15)
28
+ ------------------
29
+
30
+ * Issue - Fixed an issue with `Aws::PageableResponse` where it was modifying original params hash, causing frozen hashes to fail.
31
+
32
+ 3.114.2 (2021-06-09)
33
+ ------------------
34
+
35
+ * Issue - Fixed an issue with `Aws::PageableResponse` where intentionally nil tokens were not merged into the params for the next call.
36
+
37
+ 3.114.1 (2021-06-02)
38
+ ------------------
39
+
40
+ * Issue - Change XML Builder to not indent by default
41
+
42
+ 3.114.0 (2021-04-13)
43
+ ------------------
44
+
45
+ * Feature - Updated Aws::STS::Client with the latest API changes.
46
+
4
47
  3.113.1 (2021-03-29)
5
48
  ------------------
6
49
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.113.1
1
+ 3.118.0
@@ -160,10 +160,11 @@ module Aws
160
160
  end
161
161
 
162
162
  def instance_profile_credentials(options)
163
+ profile_name = determine_profile_name(options)
163
164
  if ENV['AWS_CONTAINER_CREDENTIALS_RELATIVE_URI']
164
165
  ECSCredentials.new(options)
165
166
  else
166
- InstanceProfileCredentials.new(options)
167
+ InstanceProfileCredentials.new(options.merge(profile: profile_name))
167
168
  end
168
169
  end
169
170
 
@@ -39,7 +39,11 @@ module Aws
39
39
  # defaulting to 6 hours.
40
40
  # @option options [Integer] :retries (3) The number of retries for failed
41
41
  # requests.
42
- # @option options [String] :endpoint (169.254.169.254) The IMDS endpoint.
42
+ # @option options [String] :endpoint ('http://169.254.169.254') The IMDS
43
+ # endpoint. This option has precedence over the :endpoint_mode.
44
+ # @option options [String] :endpoint_mode ('IPv4') The endpoint mode for
45
+ # the instance metadata service. This is either 'IPv4'
46
+ # ('http://169.254.169.254') or 'IPv6' ('http://[fd00:ec2::254]').
43
47
  # @option options [Integer] :port (80) The IMDS endpoint port.
44
48
  # @option options [Integer] :http_open_timeout (1) The number of seconds to
45
49
  # wait for the connection to open.
@@ -55,7 +59,8 @@ module Aws
55
59
  @retries = options[:retries] || 3
56
60
  @backoff = backoff(options[:backoff])
57
61
 
58
- @endpoint = options[:endpoint] || '169.254.169.254'
62
+ endpoint_mode = options[:endpoint_mode] || 'IPv4'
63
+ @endpoint = resolve_endpoint(options[:endpoint], endpoint_mode)
59
64
  @port = options[:port] || 80
60
65
 
61
66
  @http_open_timeout = options[:http_open_timeout] || 1
@@ -76,7 +81,7 @@ module Aws
76
81
  # ec2_metadata.get('/latest/meta-data/instance-id')
77
82
  # => "i-023a25f10a73a0f79"
78
83
  #
79
- # @Note This implementation always returns a String and will not parse any
84
+ # @note This implementation always returns a String and will not parse any
80
85
  # responses. Parsable responses may include JSON objects or directory
81
86
  # listings, which are strings separated by line feeds (ASCII 10).
82
87
  #
@@ -93,7 +98,7 @@ module Aws
93
98
  # listing.split(10.chr)
94
99
  # => ["ami-id", "ami-launch-index", ...]
95
100
  #
96
- # @Note Unlike other services, IMDS does not have a service API model. This
101
+ # @note Unlike other services, IMDS does not have a service API model. This
97
102
  # means that we cannot confidently generate code with methods and
98
103
  # response structures. This implementation ensures that new IMDS features
99
104
  # are always supported by being deployed to the instance and does not
@@ -116,6 +121,19 @@ module Aws
116
121
 
117
122
  private
118
123
 
124
+ def resolve_endpoint(endpoint, endpoint_mode)
125
+ return endpoint if endpoint
126
+
127
+ case endpoint_mode.downcase
128
+ when 'ipv4' then 'http://169.254.169.254'
129
+ when 'ipv6' then 'http://[fd00:ec2::254]'
130
+ else
131
+ raise ArgumentError,
132
+ ':endpoint_mode is not valid, expected IPv4 or IPv6, '\
133
+ "got: #{endpoint_mode}"
134
+ end
135
+ end
136
+
119
137
  def fetch_token
120
138
  open_connection do |conn|
121
139
  token_value, token_ttl = http_put(conn, @token_ttl)
@@ -163,7 +181,8 @@ module Aws
163
181
  end
164
182
 
165
183
  def open_connection
166
- http = Net::HTTP.new(@endpoint, @port, nil)
184
+ uri = URI.parse(@endpoint)
185
+ http = Net::HTTP.new(uri.hostname || @endpoint, @port || uri.port)
167
186
  http.open_timeout = @http_open_timeout
168
187
  http.read_timeout = @http_read_timeout
169
188
  http.set_debug_output(@http_debug_output) if @http_debug_output
@@ -210,6 +210,10 @@ module Aws
210
210
  # Raised when SSO Credentials are invalid
211
211
  class InvalidSSOCredentials < RuntimeError; end
212
212
 
213
+ # Raised when there is a circular reference in chained
214
+ # source_profiles
215
+ class SourceProfileCircularReferenceError < RuntimeError; end
216
+
213
217
  # Raised when a client is constructed and region is not specified.
214
218
  class MissingRegionError < ArgumentError
215
219
  def initialize(*args)
@@ -5,7 +5,6 @@ require 'net/http'
5
5
 
6
6
  module Aws
7
7
  class InstanceProfileCredentials
8
-
9
8
  include CredentialProvider
10
9
  include RefreshingCredentials
11
10
 
@@ -44,7 +43,13 @@ module Aws
44
43
  # @param [Hash] options
45
44
  # @option options [Integer] :retries (1) Number of times to retry
46
45
  # when retrieving credentials.
47
- # @option options [String] :ip_address ('169.254.169.254')
46
+ # @option options [String] :endpoint ('http://169.254.169.254') The IMDS
47
+ # endpoint. This option has precedence over the :endpoint_mode.
48
+ # @option options [String] :endpoint_mode ('IPv4') The endpoint mode for
49
+ # the instance metadata service. This is either 'IPv4' ('169.254.169.254')
50
+ # or 'IPv6' ('[fd00:ec2::254]').
51
+ # @option options [String] :ip_address ('169.254.169.254') Deprecated. Use
52
+ # :endpoint instead. The IP address for the endpoint.
48
53
  # @option options [Integer] :port (80)
49
54
  # @option options [Float] :http_open_timeout (1)
50
55
  # @option options [Float] :http_read_timeout (1)
@@ -60,7 +65,8 @@ module Aws
60
65
  # to 21600 seconds
61
66
  def initialize(options = {})
62
67
  @retries = options[:retries] || 1
63
- @ip_address = options[:ip_address] || '169.254.169.254'
68
+ endpoint_mode = resolve_endpoint_mode(options)
69
+ @endpoint = resolve_endpoint(options, endpoint_mode)
64
70
  @port = options[:port] || 80
65
71
  @http_open_timeout = options[:http_open_timeout] || 1
66
72
  @http_read_timeout = options[:http_read_timeout] || 1
@@ -78,6 +84,34 @@ module Aws
78
84
 
79
85
  private
80
86
 
87
+ def resolve_endpoint_mode(options)
88
+ value = options[:endpoint_mode]
89
+ value ||= ENV['AWS_EC2_METADATA_SERVICE_ENDPOINT_MODE']
90
+ value ||= Aws.shared_config.ec2_metadata_service_endpoint_mode(
91
+ profile: options[:profile]
92
+ )
93
+ value || 'IPv4'
94
+ end
95
+
96
+ def resolve_endpoint(options, endpoint_mode)
97
+ value = options[:endpoint] || options[:ip_address]
98
+ value ||= ENV['AWS_EC2_METADATA_SERVICE_ENDPOINT']
99
+ value ||= Aws.shared_config.ec2_metadata_service_endpoint(
100
+ profile: options[:profile]
101
+ )
102
+
103
+ return value if value
104
+
105
+ case endpoint_mode.downcase
106
+ when 'ipv4' then 'http://169.254.169.254'
107
+ when 'ipv6' then 'http://[fd00:ec2::254]'
108
+ else
109
+ raise ArgumentError,
110
+ ':endpoint_mode is not valid, expected IPv4 or IPv6, '\
111
+ "got: #{endpoint_mode}"
112
+ end
113
+ end
114
+
81
115
  def backoff(backoff)
82
116
  case backoff
83
117
  when Proc then backoff
@@ -152,7 +186,8 @@ module Aws
152
186
  end
153
187
 
154
188
  def open_connection
155
- http = Net::HTTP.new(@ip_address, @port, nil)
189
+ uri = URI.parse(@endpoint)
190
+ http = Net::HTTP.new(uri.hostname || @endpoint, @port || uri.port)
156
191
  http.open_timeout = @http_open_timeout
157
192
  http.read_timeout = @http_read_timeout
158
193
  http.set_debug_output(@http_debug_output) if @http_debug_output
@@ -28,8 +28,16 @@ module Aws
28
28
  member_name, member_ref = shape.member_by_location_name(key)
29
29
  if member_ref
30
30
  target[member_name] = parse_ref(member_ref, value)
31
+ elsif shape.union
32
+ target[:unknown] = { 'name' => key, 'value' => value }
31
33
  end
32
34
  end
35
+ if shape.union
36
+ # convert to subclass
37
+ member_subclass = shape.member_subclass(target.member).new
38
+ member_subclass[target.member] = target.value
39
+ target = member_subclass
40
+ end
33
41
  target
34
42
  end
35
43
 
@@ -26,7 +26,8 @@ module Aws
26
26
 
27
27
  def filter(values, type)
28
28
  case values
29
- when Struct, Hash then filter_hash(values, type)
29
+ when Struct then filter_struct(values, type)
30
+ when Hash then filter_hash(values, type)
30
31
  when Array then filter_array(values, type)
31
32
  else values
32
33
  end
@@ -34,6 +35,13 @@ module Aws
34
35
 
35
36
  private
36
37
 
38
+ def filter_struct(values, type)
39
+ if values.class.include? Aws::Structure::Union
40
+ values = { values.member => values.value }
41
+ end
42
+ filter_hash(values, type)
43
+ end
44
+
37
45
  def filter_hash(values, type)
38
46
  if type.const_defined?('SENSITIVE')
39
47
  filters = type::SENSITIVE + @additional_filters
@@ -115,7 +115,13 @@ module Aws
115
115
  # @return [Hash] Returns the hash of request parameters for the
116
116
  # next page, merging any given params.
117
117
  def next_page_params(params)
118
- context[:original_params].merge(@pager.next_tokens(self).merge(params))
118
+ # Remove all previous tokens from original params
119
+ # Sometimes a token can be nil and merge would not include it.
120
+ tokens = @pager.tokens.values.map(&:to_sym)
121
+
122
+ params_without_tokens = context[:original_params].reject { |k, _v| tokens.include?(k) }
123
+ params_without_tokens.merge!(@pager.next_tokens(self).merge(params))
124
+ params_without_tokens
119
125
  end
120
126
 
121
127
  # Raised when calling {PageableResponse#next_page} on a pager that
@@ -18,6 +18,9 @@ module Aws
18
18
  # @return [Symbol, nil]
19
19
  attr_reader :limit_key
20
20
 
21
+ # @return [Hash, nil]
22
+ attr_reader :tokens
23
+
21
24
  # @param [Seahorse::Client::Response] response
22
25
  # @return [Hash]
23
26
  def next_tokens(response)
@@ -70,6 +70,14 @@ module Aws
70
70
  end
71
71
  end
72
72
 
73
+ if @validate_required && shape.union
74
+ if values.length > 1
75
+ errors << "multiple values provided to union at #{context} - must contain exactly one of the supported types: #{shape.member_names.join(', ')}"
76
+ elsif values.length == 0
77
+ errors << "No values provided to union at #{context} - must contain exactly one of the supported types: #{shape.member_names.join(', ')}"
78
+ end
79
+ end
80
+
73
81
  # validate non-nil members
74
82
  values.each_pair do |name, value|
75
83
  unless value.nil?
@@ -163,6 +163,8 @@ module Aws
163
163
  :ca_bundle,
164
164
  :credential_process,
165
165
  :endpoint_discovery_enabled,
166
+ :ec2_metadata_service_endpoint,
167
+ :ec2_metadata_service_endpoint_mode,
166
168
  :max_attempts,
167
169
  :retry_mode,
168
170
  :adaptive_retry_wait_to_fill,
@@ -205,6 +207,7 @@ module Aws
205
207
  'a credential_source. For assume role credentials, must '\
206
208
  'provide only source_profile or credential_source, not both.'
207
209
  elsif opts[:source_profile]
210
+ opts[:visited_profiles] ||= Set.new
208
211
  opts[:credentials] = resolve_source_profile(opts[:source_profile], opts)
209
212
  if opts[:credentials]
210
213
  opts[:role_session_name] ||= prof_cfg['role_session_name']
@@ -214,6 +217,7 @@ module Aws
214
217
  opts[:external_id] ||= prof_cfg['external_id']
215
218
  opts[:serial_number] ||= prof_cfg['mfa_serial']
216
219
  opts[:profile] = opts.delete(:source_profile)
220
+ opts.delete(:visited_profiles)
217
221
  AssumeRoleCredentials.new(opts)
218
222
  else
219
223
  raise Errors::NoSourceProfileError,
@@ -246,8 +250,21 @@ module Aws
246
250
  end
247
251
 
248
252
  def resolve_source_profile(profile, opts = {})
253
+ if opts[:visited_profiles] && opts[:visited_profiles].include?(profile)
254
+ raise Errors::SourceProfileCircularReferenceError
255
+ end
256
+ opts[:visited_profiles].add(profile) if opts[:visited_profiles]
257
+
258
+ profile_config = @parsed_credentials[profile]
259
+ if @config_enabled
260
+ profile_config ||= @parsed_config[profile]
261
+ end
262
+
249
263
  if (creds = credentials(profile: profile))
250
264
  creds # static credentials
265
+ elsif profile_config && profile_config['source_profile']
266
+ opts.delete(:source_profile)
267
+ assume_role_credentials_from_config(opts.merge(profile: profile))
251
268
  elsif (provider = assume_role_web_identity_credentials_from_config(opts.merge(profile: profile)))
252
269
  provider.credentials if provider.credentials.set?
253
270
  elsif (provider = assume_role_process_credentials_from_config(profile))
@@ -274,7 +291,10 @@ module Aws
274
291
 
275
292
  def assume_role_process_credentials_from_config(profile)
276
293
  validate_profile_exists(profile)
277
- credential_process = @parsed_config[profile]['credential_process']
294
+ credential_process = @parsed_credentials.fetch(profile, {})['credential_process']
295
+ if @parsed_config
296
+ credential_process ||= @parsed_config.fetch(profile, {})['credential_process']
297
+ end
278
298
  ProcessCredentials.new(credential_process) if credential_process
279
299
  end
280
300
 
@@ -14,11 +14,17 @@ module Aws
14
14
  'aws_session_token' => 'session_token',
15
15
  }
16
16
 
17
- # Constructs a new SharedCredentials object. This will load AWS access
17
+ # Constructs a new SharedCredentials object. This will load static
18
+ # (access_key_id, secret_access_key and session_token) AWS access
18
19
  # credentials from an ini file, which supports profiles. The default
19
20
  # profile name is 'default'. You can specify the profile name with the
20
21
  # `ENV['AWS_PROFILE']` or with the `:profile_name` option.
21
22
  #
23
+ # To use credentials from the default credential resolution chain
24
+ # create a client without the credential option specified.
25
+ # You may access the resolved credentials through
26
+ # `client.config.credentials`.
27
+ #
22
28
  # @option [String] :path Path to the shared file. Defaults
23
29
  # to "#{Dir.home}/.aws/credentials".
24
30
  #
@@ -8,8 +8,7 @@ module Aws
8
8
  # AWS CLI with the correct profile.
9
9
  #
10
10
  # For more background on AWS SSO see the official
11
- # {what is SSO}[https://docs.aws.amazon.com/singlesignon/latest/userguide/what-is.html]
12
- # page.
11
+ # {https://docs.aws.amazon.com/singlesignon/latest/userguide/what-is.html what is SSO Userguide}
13
12
  #
14
13
  # ## Refreshing Credentials from SSO
15
14
  #
@@ -70,11 +70,20 @@ module Aws
70
70
  end
71
71
 
72
72
  end
73
+
74
+ module Union
75
+ def member
76
+ self.members.select { |k| self[k] }.first
77
+ end
78
+
79
+ def value
80
+ self[member] if member
81
+ end
82
+ end
73
83
  end
74
84
 
75
85
  # @api private
76
86
  class EmptyStructure < Struct.new('AwsEmptyStructure')
77
87
  include(Aws::Structure)
78
88
  end
79
-
80
89
  end
@@ -29,7 +29,7 @@ module Aws
29
29
  private
30
30
 
31
31
  def content_type(api)
32
- "application/x-amz-json-#{api.metadata['jsonVerison']}"
32
+ "application/x-amz-json-#{api.metadata['jsonVersion']}"
33
33
  end
34
34
 
35
35
  def build_body(operation, data)