aws-sdk-core 3.46.0 → 3.94.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.
Files changed (86) hide show
  1. checksums.yaml +5 -5
  2. data/VERSION +1 -1
  3. data/lib/aws-sdk-core.rb +7 -0
  4. data/lib/aws-sdk-core/arn.rb +77 -0
  5. data/lib/aws-sdk-core/arn_parser.rb +38 -0
  6. data/lib/aws-sdk-core/assume_role_web_identity_credentials.rb +102 -0
  7. data/lib/aws-sdk-core/async_client_stubs.rb +80 -0
  8. data/lib/aws-sdk-core/binary.rb +3 -0
  9. data/lib/aws-sdk-core/binary/decode_handler.rb +9 -1
  10. data/lib/aws-sdk-core/binary/encode_handler.rb +32 -0
  11. data/lib/aws-sdk-core/binary/event_builder.rb +122 -0
  12. data/lib/aws-sdk-core/binary/event_parser.rb +48 -18
  13. data/lib/aws-sdk-core/binary/event_stream_decoder.rb +5 -2
  14. data/lib/aws-sdk-core/binary/event_stream_encoder.rb +53 -0
  15. data/lib/aws-sdk-core/client_side_monitoring/publisher.rb +9 -1
  16. data/lib/aws-sdk-core/client_stubs.rb +10 -9
  17. data/lib/aws-sdk-core/credential_provider.rb +0 -31
  18. data/lib/aws-sdk-core/credential_provider_chain.rb +79 -39
  19. data/lib/aws-sdk-core/deprecations.rb +16 -10
  20. data/lib/aws-sdk-core/ecs_credentials.rb +12 -8
  21. data/lib/aws-sdk-core/endpoint_cache.rb +14 -11
  22. data/lib/aws-sdk-core/errors.rb +94 -6
  23. data/lib/aws-sdk-core/event_emitter.rb +42 -0
  24. data/lib/aws-sdk-core/instance_profile_credentials.rb +120 -38
  25. data/lib/aws-sdk-core/json.rb +13 -14
  26. data/lib/aws-sdk-core/json/error_handler.rb +19 -2
  27. data/lib/aws-sdk-core/json/handler.rb +19 -1
  28. data/lib/aws-sdk-core/log/formatter.rb +7 -1
  29. data/lib/aws-sdk-core/log/param_filter.rb +3 -3
  30. data/lib/aws-sdk-core/pageable_response.rb +34 -20
  31. data/lib/aws-sdk-core/param_validator.rb +11 -5
  32. data/lib/aws-sdk-core/plugins/client_metrics_plugin.rb +26 -1
  33. data/lib/aws-sdk-core/plugins/endpoint_discovery.rb +1 -1
  34. data/lib/aws-sdk-core/plugins/event_stream_configuration.rb +14 -0
  35. data/lib/aws-sdk-core/plugins/invocation_id.rb +33 -0
  36. data/lib/aws-sdk-core/plugins/regional_endpoint.rb +8 -1
  37. data/lib/aws-sdk-core/plugins/retries/client_rate_limiter.rb +137 -0
  38. data/lib/aws-sdk-core/plugins/retries/clock_skew.rb +98 -0
  39. data/lib/aws-sdk-core/plugins/retries/error_inspector.rb +142 -0
  40. data/lib/aws-sdk-core/plugins/retries/retry_quota.rb +57 -0
  41. data/lib/aws-sdk-core/plugins/retry_errors.rb +290 -106
  42. data/lib/aws-sdk-core/plugins/signature_v4.rb +13 -2
  43. data/lib/aws-sdk-core/plugins/stub_responses.rb +20 -7
  44. data/lib/aws-sdk-core/plugins/transfer_encoding.rb +51 -0
  45. data/lib/aws-sdk-core/plugins/user_agent.rb +4 -8
  46. data/lib/aws-sdk-core/process_credentials.rb +9 -3
  47. data/lib/aws-sdk-core/shared_config.rb +95 -125
  48. data/lib/aws-sdk-core/structure.rb +1 -2
  49. data/lib/aws-sdk-core/stubbing/protocols/rest.rb +19 -0
  50. data/lib/aws-sdk-core/stubbing/stub_data.rb +13 -4
  51. data/lib/aws-sdk-core/util.rb +4 -0
  52. data/lib/aws-sdk-core/waiters/waiter.rb +2 -2
  53. data/lib/aws-sdk-core/xml/error_handler.rb +26 -3
  54. data/lib/aws-sdk-sts.rb +7 -4
  55. data/lib/aws-sdk-sts/client.rb +1109 -459
  56. data/lib/aws-sdk-sts/client_api.rb +67 -0
  57. data/lib/aws-sdk-sts/customizations.rb +2 -0
  58. data/lib/aws-sdk-sts/errors.rb +150 -0
  59. data/lib/aws-sdk-sts/plugins/sts_regional_endpoints.rb +32 -0
  60. data/lib/aws-sdk-sts/presigner.rb +67 -0
  61. data/lib/aws-sdk-sts/resource.rb +1 -0
  62. data/lib/aws-sdk-sts/types.rb +736 -176
  63. data/lib/seahorse.rb +9 -0
  64. data/lib/seahorse/client/async_base.rb +50 -0
  65. data/lib/seahorse/client/async_response.rb +62 -0
  66. data/lib/seahorse/client/base.rb +4 -2
  67. data/lib/seahorse/client/configuration.rb +4 -2
  68. data/lib/seahorse/client/events.rb +1 -1
  69. data/lib/seahorse/client/h2/connection.rb +246 -0
  70. data/lib/seahorse/client/h2/handler.rb +151 -0
  71. data/lib/seahorse/client/handler_list_entry.rb +2 -2
  72. data/lib/seahorse/client/http/async_response.rb +42 -0
  73. data/lib/seahorse/client/http/response.rb +13 -8
  74. data/lib/seahorse/client/logging/formatter.rb +4 -2
  75. data/lib/seahorse/client/net_http/connection_pool.rb +19 -20
  76. data/lib/seahorse/client/net_http/handler.rb +7 -1
  77. data/lib/seahorse/client/net_http/patches.rb +7 -1
  78. data/lib/seahorse/client/networking_error.rb +28 -0
  79. data/lib/seahorse/client/plugin.rb +5 -4
  80. data/lib/seahorse/client/plugins/content_length.rb +5 -2
  81. data/lib/seahorse/client/plugins/h2.rb +64 -0
  82. data/lib/seahorse/client/response.rb +3 -5
  83. data/lib/seahorse/model/api.rb +4 -0
  84. data/lib/seahorse/model/operation.rb +4 -0
  85. data/lib/seahorse/model/shapes.rb +2 -2
  86. metadata +43 -10
@@ -6,10 +6,14 @@ module Aws
6
6
  include Seahorse::Model::Shapes
7
7
 
8
8
  # @param [Class] parser_class
9
- # @param [Seahorse::Model::ShapeRef] rules
10
- def initialize(parser_class, rules)
9
+ # @param [Seahorse::Model::ShapeRef] rules (of eventstream member)
10
+ # @param [Array] error_refs array of errors ShapeRef
11
+ # @param [Seahorse::Model::ShapeRef] output_ref
12
+ def initialize(parser_class, rules, error_refs, output_ref)
11
13
  @parser_class = parser_class
12
14
  @rules = rules
15
+ @error_refs = error_refs
16
+ @output_ref = output_ref
13
17
  end
14
18
 
15
19
  # Parse raw event message into event struct
@@ -31,9 +35,7 @@ module Aws
31
35
  when 'event'
32
36
  parse_event(raw_event)
33
37
  when 'exception'
34
- # Pending
35
- raise Aws::Errors::EventStreamParserError.new(
36
- ':exception event parsing is not supported')
38
+ parse_exception(raw_event)
37
39
  else
38
40
  raise Aws::Errors::EventStreamParserError.new(
39
41
  'Unrecognized :message-type value for the event')
@@ -44,6 +46,15 @@ module Aws
44
46
  end
45
47
  end
46
48
 
49
+ def parse_exception(raw_event)
50
+ exception_type = raw_event.headers.delete(":exception-type").value
51
+ name, ref = @rules.shape.member_by_location_name(exception_type)
52
+ # exception lives in payload implictly
53
+ exception = parse_payload(raw_event.payload.read, ref)
54
+ exception.event_type = name
55
+ exception
56
+ end
57
+
47
58
  def parse_error_event(raw_event)
48
59
  error_code = raw_event.headers.delete(":error-code")
49
60
  error_message = raw_event.headers.delete(":error-message")
@@ -58,35 +69,54 @@ module Aws
58
69
  event_type = raw_event.headers.delete(":event-type").value
59
70
  # content_type = raw_event.headers.delete(":content-type").value
60
71
 
61
- # Pending
62
72
  if event_type == 'initial-response'
63
- raise Aws::Errors::EventStreamParserError.new(
64
- 'non eventstream member at response is not supported yet'
65
- )
73
+ event = Struct.new(:event_type, :response).new
74
+ event.event_type = :initial_response
75
+ event.response = parse_payload(raw_event.payload.read, @output_ref)
76
+ return event
66
77
  end
67
78
 
68
79
  # locate event from eventstream
69
80
  name, ref = @rules.shape.member_by_location_name(event_type)
70
- raise "Non event member found at eventstream" unless ref.event
81
+ unless ref.event
82
+ raise Aws::Errors::EventStreamParserError.new(
83
+ "Failed to locate event shape for the event")
84
+ end
71
85
 
72
86
  event = ref.shape.struct_class.new
87
+
88
+ explicit_payload = false
89
+ implicit_payload_members = {}
90
+ ref.shape.members.each do |member_name, member_ref|
91
+ unless member_ref.eventheader
92
+ if member_ref.eventpayload
93
+ explicit_payload = true
94
+ else
95
+ implicit_payload_members[member_name] = member_ref
96
+ end
97
+ end
98
+ end
99
+
100
+ # implicit payload
101
+ if !explicit_payload && !implicit_payload_members.empty?
102
+ event = parse_payload(raw_event.payload.read, ref)
103
+ end
73
104
  event.event_type = name
105
+
74
106
  # locate payload and headers in the event
75
107
  ref.shape.members.each do |member_name, member_ref|
76
- if member_ref.eventpayload
77
- eventpayload_streaming?(member_ref) ?
78
- event.send("#{member_name}=", raw_event.payload) :
79
- event.send("#{member_name}=", parse_payload(raw_event.payload.read, member_ref))
80
- elsif member_ref.eventheader
108
+ if member_ref.eventheader
81
109
  # allow incomplete event members in response
82
110
  if raw_event.headers.key?(member_ref.location_name)
83
111
  event.send("#{member_name}=", raw_event.headers[member_ref.location_name].value)
84
112
  end
85
- else
86
- raise "Non eventpayload or eventheader member found at event"
113
+ elsif member_ref.eventpayload
114
+ # explicit payload
115
+ eventpayload_streaming?(member_ref) ?
116
+ event.send("#{member_name}=", raw_event.payload) :
117
+ event.send("#{member_name}=", parse_payload(raw_event.payload.read, member_ref))
87
118
  end
88
119
  end
89
-
90
120
  event
91
121
  end
92
122
 
@@ -7,11 +7,13 @@ module Aws
7
7
 
8
8
  # @param [String] protocol
9
9
  # @param [ShapeRef] rules ShapeRef of the eventstream member
10
+ # @param [ShapeRef] output_ref ShapeRef of output shape
11
+ # @param [Array] error_refs array of ShapeRefs for errors
10
12
  # @param [EventStream|nil] event_stream_handler A Service EventStream object
11
13
  # that registered with callbacks for processing events when they arrive
12
- def initialize(protocol, rules, io, event_stream_handler = nil)
14
+ def initialize(protocol, rules, output_ref, error_refs, io, event_stream_handler = nil)
13
15
  @decoder = Aws::EventStream::Decoder.new
14
- @event_parser = EventParser.new(parser_class(protocol), rules)
16
+ @event_parser = EventParser.new(parser_class(protocol), rules, error_refs, output_ref)
15
17
  @stream_class = extract_stream_class(rules.shape.struct_class)
16
18
  @emitter = event_stream_handler.event_emitter
17
19
  @events = []
@@ -42,6 +44,7 @@ module Aws
42
44
  case protocol
43
45
  when 'rest-xml' then Aws::Xml::Parser
44
46
  when 'rest-json' then Aws::Json::Parser
47
+ when 'json' then Aws::Json::Parser
45
48
  else raise "unsupported protocol #{protocol} for event stream"
46
49
  end
47
50
  end
@@ -0,0 +1,53 @@
1
+ require 'aws-eventstream'
2
+
3
+ module Aws
4
+ module Binary
5
+ # @api private
6
+ class EventStreamEncoder
7
+
8
+ # @param [String] protocol
9
+ # @param [ShapeRef] rules ShapeRef of the eventstream member
10
+ # @param [ShapeRef] input_ref ShapeRef of the input shape
11
+ # @param [Aws::Sigv4::Signer] signer
12
+ def initialize(protocol, rules, input_ref, signer)
13
+ @encoder = Aws::EventStream::Encoder.new
14
+ @event_builder = EventBuilder.new(serializer_class(protocol), rules)
15
+ @input_ref = input_ref
16
+ @rules = rules
17
+ @signer = signer
18
+ @prior_signature = nil
19
+ end
20
+
21
+ attr_reader :rules
22
+
23
+ attr_accessor :prior_signature
24
+
25
+ def encode(event_type, params)
26
+ if event_type == :end_stream
27
+ payload = ''
28
+ else
29
+ payload = @encoder.encode(@event_builder.apply(event_type, params))
30
+ end
31
+ headers, signature = @signer.sign_event(@prior_signature, payload, @encoder)
32
+ @prior_signature = signature
33
+ message = Aws::EventStream::Message.new(
34
+ headers: headers,
35
+ payload: StringIO.new(payload)
36
+ )
37
+ @encoder.encode(message)
38
+ end
39
+
40
+ private
41
+
42
+ def serializer_class(protocol)
43
+ case protocol
44
+ when 'rest-xml' then Xml::Builder
45
+ when 'rest-json' then Json::Builder
46
+ when 'json' then Json::Builder
47
+ else raise "unsupported protocol #{protocol} for event stream"
48
+ end
49
+ end
50
+
51
+ end
52
+ end
53
+ end
@@ -6,8 +6,10 @@ module Aws
6
6
  # @api private
7
7
  class Publisher
8
8
  attr_reader :agent_port
9
+ attr_reader :agent_host
9
10
 
10
11
  def initialize(opts = {})
12
+ @agent_host = opts[:agent_host] || "127.0.0.1"
11
13
  @agent_port = opts[:agent_port]
12
14
  @mutex = Mutex.new
13
15
  end
@@ -18,6 +20,12 @@ module Aws
18
20
  end
19
21
  end
20
22
 
23
+ def agent_host=(value)
24
+ @mutex.synchronize do
25
+ @agent_host = value
26
+ end
27
+ end
28
+
21
29
  def publish(request_metrics)
22
30
  send_datagram(request_metrics.api_call.to_json)
23
31
  request_metrics.api_call_attempts.each do |attempt|
@@ -29,7 +37,7 @@ module Aws
29
37
  if @agent_port
30
38
  socket = UDPSocket.new
31
39
  begin
32
- socket.connect("127.0.0.1", @agent_port)
40
+ socket.connect(@agent_host, @agent_port)
33
41
  socket.send(msg, 0)
34
42
  rescue Errno::ECONNREFUSED
35
43
  # Drop on the floor
@@ -171,7 +171,6 @@ module Aws
171
171
  # @raise [RuntimeError] Raises a runtime error when called
172
172
  # on a client that has not enabled response stubbing via
173
173
  # `:stub_responses => true`.
174
- #
175
174
  def stub_responses(operation_name, *stubs)
176
175
  if config.stub_responses
177
176
  apply_stubs(operation_name, stubs.flatten)
@@ -182,13 +181,15 @@ module Aws
182
181
  end
183
182
  end
184
183
 
185
- # Allows you to access all of the requests that the stubbed client has made
186
- #
187
- # @params [Boolean] exclude_presign Setting to true for filtering out not sent requests from
188
- # generating presigned urls. Default to false.
189
- # @return [Array] Returns an array of the api requests made, each request object contains the
190
- # :operation_name, :params, and :context of the request.
191
- # @raise [NotImplementedError] Raises `NotImplementedError` when the client is not stubbed
184
+ # Allows you to access all of the requests that the stubbed client has made.
185
+ #
186
+ # @param [Hash] options The options for the api requests.
187
+ # @option options [Boolean] :exclude_presign (false) Set to true to filter
188
+ # out unsent requests from generated presigned urls.
189
+ # @return [Array] Returns an array of the api requests made. Each request
190
+ # object contains the :operation_name, :params, and :context.
191
+ # @raise [NotImplementedError] Raises `NotImplementedError` when the client
192
+ # is not stubbed.
192
193
  def api_requests(options = {})
193
194
  if config.stub_responses
194
195
  if options[:exclude_presign]
@@ -291,7 +292,7 @@ module Aws
291
292
  def data_to_http_resp(operation_name, data)
292
293
  api = config.api
293
294
  operation = api.operation(operation_name)
294
- ParamValidator.validate!(operation.output, data)
295
+ ParamValidator.new(operation.output, input: false).validate!(data)
295
296
  protocol_helper.stub_data(api, operation, data)
296
297
  end
297
298
 
@@ -1,10 +1,6 @@
1
- require_relative 'deprecations'
2
-
3
1
  module Aws
4
2
  module CredentialProvider
5
3
 
6
- extend Deprecations
7
-
8
4
  # @return [Credentials]
9
5
  attr_reader :credentials
10
6
 
@@ -13,32 +9,5 @@ module Aws
13
9
  !!credentials && credentials.set?
14
10
  end
15
11
 
16
- # @deprecated Deprecated in 2.1.0. This method is subject to errors
17
- # from a race condition when called against refreshable credential
18
- # objects. Will be removed in 2.2.0.
19
- # @see #credentials
20
- def access_key_id
21
- credentials ? credentials.access_key_id : nil
22
- end
23
- deprecated(:access_key_id, use: '#credentials')
24
-
25
- # @deprecated Deprecated in 2.1.0. This method is subject to errors
26
- # from a race condition when called against refreshable credential
27
- # objects. Will be removed in 2.2.0.
28
- # @see #credentials
29
- def secret_access_key
30
- credentials ? credentials.secret_access_key : nil
31
- end
32
- deprecated(:secret_access_key, use: '#credentials')
33
-
34
- # @deprecated Deprecated in 2.1.0. This method is subject to errors
35
- # from a race condition when called against refreshable credential
36
- # objects. Will be removed in 2.2.0.
37
- # @see #credentials
38
- def session_token
39
- credentials ? credentials.session_token : nil
40
- end
41
- deprecated(:session_token, use: '#credentials')
42
-
43
12
  end
44
13
  end
@@ -1,7 +1,6 @@
1
1
  module Aws
2
2
  # @api private
3
3
  class CredentialProviderChain
4
-
5
4
  def initialize(config = nil)
6
5
  @config = config
7
6
  end
@@ -20,15 +19,20 @@ module Aws
20
19
  def providers
21
20
  [
22
21
  [:static_credentials, {}],
22
+ [:static_profile_assume_role_web_identity_credentials, {}],
23
+ [:static_profile_assume_role_credentials, {}],
24
+ [:static_profile_credentials, {}],
25
+ [:static_profile_process_credentials, {}],
23
26
  [:env_credentials, {}],
27
+ [:assume_role_web_identity_credentials, {}],
24
28
  [:assume_role_credentials, {}],
25
29
  [:shared_credentials, {}],
26
30
  [:process_credentials, {}],
27
31
  [:instance_profile_credentials, {
28
32
  retries: @config ? @config.instance_profile_credentials_retries : 0,
29
33
  http_open_timeout: @config ? @config.instance_profile_credentials_timeout : 1,
30
- http_read_timeout: @config ? @config.instance_profile_credentials_timeout : 1,
31
- }],
34
+ http_read_timeout: @config ? @config.instance_profile_credentials_timeout : 1
35
+ }]
32
36
  ]
33
37
  end
34
38
 
@@ -37,48 +41,73 @@ module Aws
37
41
  Credentials.new(
38
42
  options[:config].access_key_id,
39
43
  options[:config].secret_access_key,
40
- options[:config].session_token)
41
- else
42
- nil
44
+ options[:config].session_token
45
+ )
46
+ end
47
+ end
48
+
49
+ def static_profile_assume_role_web_identity_credentials(options)
50
+ if Aws.shared_config.config_enabled? && options[:config] && options[:config].profile
51
+ Aws.shared_config.assume_role_web_identity_credentials_from_config(
52
+ profile: options[:config].profile,
53
+ region: options[:config].region
54
+ )
55
+ end
56
+ end
57
+
58
+ def static_profile_assume_role_credentials(options)
59
+ if Aws.shared_config.config_enabled? && options[:config] && options[:config].profile
60
+ assume_role_with_profile(options, options[:config].profile)
43
61
  end
44
62
  end
45
63
 
46
- def env_credentials(options)
47
- key = %w(AWS_ACCESS_KEY_ID AMAZON_ACCESS_KEY_ID AWS_ACCESS_KEY)
48
- secret = %w(AWS_SECRET_ACCESS_KEY AMAZON_SECRET_ACCESS_KEY AWS_SECRET_KEY)
49
- token = %w(AWS_SESSION_TOKEN AMAZON_SESSION_TOKEN)
64
+ def static_profile_credentials(options)
65
+ if options[:config] && options[:config].profile
66
+ SharedCredentials.new(profile_name: options[:config].profile)
67
+ end
68
+ rescue Errors::NoSuchProfileError
69
+ nil
70
+ end
71
+
72
+ def static_profile_process_credentials(options)
73
+ if Aws.shared_config.config_enabled? && options[:config] && options[:config].profile
74
+ process_provider = Aws.shared_config.credential_process(profile: options[:config].profile)
75
+ ProcessCredentials.new(process_provider) if process_provider
76
+ end
77
+ rescue Errors::NoSuchProfileError
78
+ nil
79
+ end
80
+
81
+ def env_credentials(_options)
82
+ key = %w[AWS_ACCESS_KEY_ID AMAZON_ACCESS_KEY_ID AWS_ACCESS_KEY]
83
+ secret = %w[AWS_SECRET_ACCESS_KEY AMAZON_SECRET_ACCESS_KEY AWS_SECRET_KEY]
84
+ token = %w[AWS_SESSION_TOKEN AMAZON_SESSION_TOKEN]
50
85
  Credentials.new(envar(key), envar(secret), envar(token))
51
86
  end
52
87
 
53
88
  def envar(keys)
54
89
  keys.each do |key|
55
- if ENV.key?(key)
56
- return ENV[key]
57
- end
90
+ return ENV[key] if ENV.key?(key)
58
91
  end
59
92
  nil
60
93
  end
61
94
 
95
+ def determine_profile_name(options)
96
+ (options[:config] && options[:config].profile) || ENV['AWS_PROFILE'] || ENV['AWS_DEFAULT_PROFILE'] || 'default'
97
+ end
98
+
62
99
  def shared_credentials(options)
63
- if options[:config]
64
- SharedCredentials.new(profile_name: options[:config].profile)
65
- else
66
- SharedCredentials.new(
67
- profile_name: ENV['AWS_PROFILE'].nil? ? 'default' : ENV['AWS_PROFILE'])
68
- end
100
+ profile_name = determine_profile_name(options)
101
+ SharedCredentials.new(profile_name: profile_name)
69
102
  rescue Errors::NoSuchProfileError
70
103
  nil
71
104
  end
72
105
 
73
106
  def process_credentials(options)
74
- profile_name = options[:config].profile if options[:config]
75
- profile_name ||= ENV['AWS_PROFILE'].nil? ? 'default' : ENV['AWS_PROFILE']
76
-
77
- config = Aws.shared_config
78
- if config.config_enabled? && process_provider = config.credentials_process(profile_name)
107
+ profile_name = determine_profile_name(options)
108
+ if Aws.shared_config.config_enabled? &&
109
+ (process_provider = Aws.shared_config.credential_process(profile: profile_name))
79
110
  ProcessCredentials.new(process_provider)
80
- else
81
- nil
82
111
  end
83
112
  rescue Errors::NoSuchProfileError
84
113
  nil
@@ -86,33 +115,44 @@ module Aws
86
115
 
87
116
  def assume_role_credentials(options)
88
117
  if Aws.shared_config.config_enabled?
89
- profile, region = nil, nil
90
- if options[:config]
91
- profile = options[:config].profile
92
- region = options[:config].region
93
- assume_role_with_profile(options[:config].profile, options[:config].region)
94
- end
95
- assume_role_with_profile(profile, region)
96
- else
97
- nil
118
+ assume_role_with_profile(options, determine_profile_name(options))
119
+ end
120
+ end
121
+
122
+ def assume_role_web_identity_credentials(options)
123
+ region = options[:config].region if options[:config]
124
+ if (role_arn = ENV['AWS_ROLE_ARN']) && (token_file = ENV['AWS_WEB_IDENTITY_TOKEN_FILE'])
125
+ cfg = {
126
+ role_arn: role_arn,
127
+ web_identity_token_file: token_file,
128
+ role_session_name: ENV['AWS_ROLE_SESSION_NAME']
129
+ }
130
+ cfg[:region] = region if region
131
+ AssumeRoleWebIdentityCredentials.new(cfg)
132
+ elsif Aws.shared_config.config_enabled?
133
+ profile = options[:config].profile if options[:config]
134
+ Aws.shared_config.assume_role_web_identity_credentials_from_config(
135
+ profile: profile,
136
+ region: region
137
+ )
98
138
  end
99
139
  end
100
140
 
101
141
  def instance_profile_credentials(options)
102
- if ENV["AWS_CONTAINER_CREDENTIALS_RELATIVE_URI"]
142
+ if ENV['AWS_CONTAINER_CREDENTIALS_RELATIVE_URI']
103
143
  ECSCredentials.new(options)
104
144
  else
105
145
  InstanceProfileCredentials.new(options)
106
146
  end
107
147
  end
108
148
 
109
- def assume_role_with_profile(prof, region)
149
+ def assume_role_with_profile(options, profile_name)
150
+ region = (options[:config] && options[:config].region)
110
151
  Aws.shared_config.assume_role_credentials_from_config(
111
- profile: prof,
152
+ profile: profile_name,
112
153
  region: region,
113
154
  chain_config: @config
114
155
  )
115
156
  end
116
-
117
157
  end
118
158
  end