aws-sdk-core 3.114.3 → 3.118.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a2a923ececa57310eb125e17602c198dd858b3960e1a337d330eb1227aff96d0
4
- data.tar.gz: f3d256f8d55d40e00e1647946eae2df2d6380de20f874e219015ae47de6af456
3
+ metadata.gz: f880e91159fbbd13553271c925b06c11172de5ffda9f8931ae4ee66b09160100
4
+ data.tar.gz: 47f884e80449f6bffacc2babc3f96ba2248694aaab27da5bdbbaf895f29a0ec5
5
5
  SHA512:
6
- metadata.gz: 8d1be434b0538cc3608d27bda7e1be4a5f4ae43dc12dc81c66edf577cd5221351b8053996008a413bef6f81cf1a6cf7f68f11292c2c5308addd6fb2c993b2d3a
7
- data.tar.gz: 6acdb965572b57ca443761b9d23c34f662d7ad391345c65a534d3409f5caaa427b3dc929774e8c0393eb21ee0829d92b8d7adf039b8e928a069441e2ee7f1c3c
6
+ metadata.gz: d776a66ce68988249850ffb707f23cabc7097232042dcb4425bdb1dc027a445d6adeacfb496758340cf66865cf2e5597c6d3ae67b48d81814b24d1d40ecdc6d9
7
+ data.tar.gz: afe710d79ca075dfa33da32ef42356f0ccc60362bb6b66d0aa76f5171141df24418288b48e3c12bb0fd40c8a650cee273177756a7993b4b44099f83f2b7c8253
data/CHANGELOG.md CHANGED
@@ -1,6 +1,29 @@
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
+
4
27
  3.114.3 (2021-06-15)
5
28
  ------------------
6
29
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.114.3
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
@@ -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
  #
@@ -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
@@ -95,6 +95,8 @@ module Aws
95
95
  def child_frame(xml_name)
96
96
  if @member = @members[xml_name]
97
97
  Frame.new(xml_name, self, @member[:ref])
98
+ elsif @ref.shape.union
99
+ UnknownMemberFrame.new(xml_name, self, nil, @result)
98
100
  else
99
101
  NullFrame.new(xml_name, self)
100
102
  end
@@ -106,10 +108,24 @@ module Aws
106
108
  @result[@member[:name]][child.key.result] = child.value.result
107
109
  when FlatListFrame
108
110
  @result[@member[:name]] << child.result
111
+ when UnknownMemberFrame
112
+ @result[:unknown] = { 'name' => child.path.last, 'value' => child.result }
109
113
  when NullFrame
110
114
  else
111
115
  @result[@member[:name]] = child.result
112
116
  end
117
+
118
+ if @ref.shape.union
119
+ # a union may only have one member set
120
+ # convert to the union subclass
121
+ # The default Struct created will have defaults set for all values
122
+ # This also sets only one of the values leaving everything else nil
123
+ # as required for unions
124
+ set_member_name = @member ? @member[:name] : :unknown
125
+ member_subclass = @ref.shape.member_subclass(set_member_name).new # shape.member_subclass(target.member).new
126
+ member_subclass[set_member_name] = @result[set_member_name]
127
+ @result = member_subclass
128
+ end
113
129
  end
114
130
 
115
131
  private
@@ -242,6 +258,12 @@ module Aws
242
258
  end
243
259
  end
244
260
 
261
+ class UnknownMemberFrame < Frame
262
+ def result
263
+ @text.join
264
+ end
265
+ end
266
+
245
267
  class BlobFrame < Frame
246
268
  def result
247
269
  @text.empty? ? nil : Base64.decode64(@text.join)
@@ -302,6 +324,7 @@ module Aws
302
324
  MapShape => MapFrame,
303
325
  StringShape => StringFrame,
304
326
  StructureShape => StructureFrame,
327
+ UnionShape => StructureFrame,
305
328
  TimestampShape => TimestampFrame,
306
329
  }
307
330
 
data/lib/aws-sdk-sso.rb CHANGED
@@ -50,6 +50,6 @@ require_relative 'aws-sdk-sso/customizations'
50
50
  # @!group service
51
51
  module Aws::SSO
52
52
 
53
- GEM_VERSION = '3.114.3'
53
+ GEM_VERSION = '3.118.0'
54
54
 
55
55
  end
@@ -523,7 +523,7 @@ module Aws::SSO
523
523
  params: params,
524
524
  config: config)
525
525
  context[:gem_name] = 'aws-sdk-core'
526
- context[:gem_version] = '3.114.3'
526
+ context[:gem_version] = '3.118.0'
527
527
  Seahorse::Client::Request.new(handlers, context)
528
528
  end
529
529