aws-sdk-s3 1.88.1 → 1.105.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +833 -0
- data/LICENSE.txt +202 -0
- data/VERSION +1 -0
- data/lib/aws-sdk-s3/arn/access_point_arn.rb +14 -11
- data/lib/aws-sdk-s3/arn/multi_region_access_point_arn.rb +68 -0
- data/lib/aws-sdk-s3/arn/object_lambda_arn.rb +69 -0
- data/lib/aws-sdk-s3/arn/outpost_access_point_arn.rb +9 -10
- data/lib/aws-sdk-s3/bucket.rb +30 -29
- data/lib/aws-sdk-s3/bucket_acl.rb +9 -6
- data/lib/aws-sdk-s3/bucket_cors.rb +8 -7
- data/lib/aws-sdk-s3/bucket_lifecycle.rb +6 -5
- data/lib/aws-sdk-s3/bucket_lifecycle_configuration.rb +3 -3
- data/lib/aws-sdk-s3/bucket_logging.rb +6 -6
- data/lib/aws-sdk-s3/bucket_notification.rb +4 -4
- data/lib/aws-sdk-s3/bucket_policy.rb +6 -5
- data/lib/aws-sdk-s3/bucket_request_payment.rb +8 -8
- data/lib/aws-sdk-s3/bucket_tagging.rb +6 -5
- data/lib/aws-sdk-s3/bucket_versioning.rb +13 -10
- data/lib/aws-sdk-s3/bucket_website.rb +6 -5
- data/lib/aws-sdk-s3/client.rb +1823 -1323
- data/lib/aws-sdk-s3/client_api.rb +65 -1
- data/lib/aws-sdk-s3/customizations/bucket.rb +8 -3
- data/lib/aws-sdk-s3/customizations/object.rb +41 -16
- data/lib/aws-sdk-s3/encryption/client.rb +1 -1
- data/lib/aws-sdk-s3/encryption/decrypt_handler.rb +0 -4
- data/lib/aws-sdk-s3/encryptionV2/client.rb +1 -1
- data/lib/aws-sdk-s3/encryptionV2/decrypt_handler.rb +0 -4
- data/lib/aws-sdk-s3/encryptionV2/encrypt_handler.rb +0 -4
- data/lib/aws-sdk-s3/errors.rb +1 -1
- data/lib/aws-sdk-s3/event_streams.rb +1 -1
- data/lib/aws-sdk-s3/file_downloader.rb +6 -1
- data/lib/aws-sdk-s3/file_uploader.rb +3 -3
- data/lib/aws-sdk-s3/multipart_upload.rb +7 -7
- data/lib/aws-sdk-s3/multipart_upload_part.rb +9 -8
- data/lib/aws-sdk-s3/object.rb +164 -75
- data/lib/aws-sdk-s3/object_acl.rb +10 -7
- data/lib/aws-sdk-s3/object_summary.rb +75 -71
- data/lib/aws-sdk-s3/object_version.rb +18 -17
- data/lib/aws-sdk-s3/plugins/accelerate.rb +7 -1
- data/lib/aws-sdk-s3/plugins/arn.rb +91 -42
- data/lib/aws-sdk-s3/plugins/bucket_dns.rb +1 -1
- data/lib/aws-sdk-s3/plugins/dualstack.rb +25 -31
- data/lib/aws-sdk-s3/plugins/get_bucket_location_fix.rb +1 -1
- data/lib/aws-sdk-s3/plugins/iad_regional_endpoint.rb +11 -10
- data/lib/aws-sdk-s3/plugins/object_lambda_endpoint.rb +25 -0
- data/lib/aws-sdk-s3/plugins/s3_signer.rb +35 -5
- data/lib/aws-sdk-s3/presigner.rb +19 -5
- data/lib/aws-sdk-s3/resource.rb +5 -3
- data/lib/aws-sdk-s3/types.rb +1397 -845
- data/lib/aws-sdk-s3/waiters.rb +1 -1
- data/lib/aws-sdk-s3.rb +2 -2
- metadata +17 -12
@@ -1,7 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative '../arn/access_point_arn'
|
4
|
+
require_relative '../arn/object_lambda_arn'
|
4
5
|
require_relative '../arn/outpost_access_point_arn'
|
6
|
+
require_relative '../arn/multi_region_access_point_arn'
|
5
7
|
|
6
8
|
module Aws
|
7
9
|
module S3
|
@@ -22,9 +24,21 @@ be made. Set to `false` to use the client's region instead.
|
|
22
24
|
resolve_s3_use_arn_region(cfg)
|
23
25
|
end
|
24
26
|
|
25
|
-
|
27
|
+
option(
|
28
|
+
:s3_disable_multiregion_access_points,
|
29
|
+
default: false,
|
30
|
+
doc_type: 'Boolean',
|
31
|
+
docstring: <<-DOCS) do |cfg|
|
32
|
+
When set to `false` this will option will raise errors when multi-region
|
33
|
+
access point ARNs are used. Multi-region access points can potentially
|
34
|
+
result in cross region requests.
|
35
|
+
DOCS
|
36
|
+
resolve_s3_disable_multiregion_access_points(cfg)
|
37
|
+
end
|
38
|
+
|
39
|
+
# param validator is validate:50
|
26
40
|
# endpoint is build:90 (populates the URI for the first time)
|
27
|
-
# endpoint pattern is build:10
|
41
|
+
# endpoint pattern is build:10
|
28
42
|
def add_handlers(handlers, _config)
|
29
43
|
handlers.add(ARNHandler, step: :validate, priority: 75)
|
30
44
|
handlers.add(UrlHandler)
|
@@ -38,6 +52,7 @@ be made. Set to `false` to use the client's region instead.
|
|
38
52
|
context.http_request.endpoint,
|
39
53
|
context.metadata[:s3_arn][:arn],
|
40
54
|
context.metadata[:s3_arn][:resolved_region],
|
55
|
+
context.metadata[:s3_arn][:fips],
|
41
56
|
context.metadata[:s3_arn][:dualstack],
|
42
57
|
# if regional_endpoint is false, a custom endpoint was provided
|
43
58
|
# in this case, we want to prefix the endpoint using the ARN
|
@@ -65,6 +80,7 @@ be made. Set to `false` to use the client's region instead.
|
|
65
80
|
context.metadata[:s3_arn] = {
|
66
81
|
arn: arn,
|
67
82
|
resolved_region: resolved_region,
|
83
|
+
fips: context.config.use_fips_endpoint,
|
68
84
|
dualstack: extract_dualstack_config!(context)
|
69
85
|
}
|
70
86
|
end
|
@@ -103,8 +119,21 @@ be made. Set to `false` to use the client's region instead.
|
|
103
119
|
|
104
120
|
if !arn.support_dualstack? && context[:use_dualstack_endpoint]
|
105
121
|
raise ArgumentError,
|
106
|
-
'Cannot provide an Outpost Access Point
|
107
|
-
'
|
122
|
+
'Cannot provide an Outpost Access Point, Object Lambda, '\
|
123
|
+
'or Multi-region Access Point ARN'\
|
124
|
+
' when `:use_dualstack_endpoint` is set to true.'
|
125
|
+
end
|
126
|
+
|
127
|
+
if arn.region.empty? && context.config.s3_disable_multiregion_access_points
|
128
|
+
raise ArgumentError,
|
129
|
+
'Cannot provide a Multi-region Access Point ARN with '\
|
130
|
+
'`:s3_disable_multiregion_access_points` set to true'
|
131
|
+
end
|
132
|
+
|
133
|
+
if context.config.use_fips_endpoint && !arn.support_fips?
|
134
|
+
raise ArgumentError,
|
135
|
+
'FIPS client regions are not supported for this type '\
|
136
|
+
'of ARN.'
|
108
137
|
end
|
109
138
|
end
|
110
139
|
end
|
@@ -114,15 +143,7 @@ be made. Set to `false` to use the client's region instead.
|
|
114
143
|
def resolve_arn!(member_value, region, use_arn_region)
|
115
144
|
if Aws::ARNParser.arn?(member_value)
|
116
145
|
arn = Aws::ARNParser.parse(member_value)
|
117
|
-
|
118
|
-
s3_arn = Aws::S3::AccessPointARN.new(arn.to_h)
|
119
|
-
elsif arn.resource.start_with?('outpost')
|
120
|
-
s3_arn = Aws::S3::OutpostAccessPointARN.new(arn.to_h)
|
121
|
-
else
|
122
|
-
raise ArgumentError,
|
123
|
-
'Only Access Point and Outpost Access Point type ARNs '\
|
124
|
-
'are currently supported.'
|
125
|
-
end
|
146
|
+
s3_arn = resolve_arn_type!(arn)
|
126
147
|
s3_arn.validate_arn!
|
127
148
|
validate_region_config!(s3_arn, region, use_arn_region)
|
128
149
|
region = s3_arn.region if use_arn_region
|
@@ -133,15 +154,32 @@ be made. Set to `false` to use the client's region instead.
|
|
133
154
|
end
|
134
155
|
|
135
156
|
# @api private
|
136
|
-
def resolve_url!(url, arn, region, dualstack = false, has_custom_endpoint = false)
|
157
|
+
def resolve_url!(url, arn, region, fips = false, dualstack = false, has_custom_endpoint = false)
|
137
158
|
custom_endpoint = url.host if has_custom_endpoint
|
138
|
-
url.host = arn.host_url(region, dualstack, custom_endpoint)
|
159
|
+
url.host = arn.host_url(region, fips, dualstack, custom_endpoint)
|
139
160
|
url.path = url_path(url.path, arn)
|
140
161
|
url
|
141
162
|
end
|
142
163
|
|
143
164
|
private
|
144
165
|
|
166
|
+
def resolve_arn_type!(arn)
|
167
|
+
case arn.service
|
168
|
+
when 's3'
|
169
|
+
arn.region.empty? ?
|
170
|
+
Aws::S3::MultiRegionAccessPointARN.new(arn.to_h) :
|
171
|
+
Aws::S3::AccessPointARN.new(arn.to_h)
|
172
|
+
when 's3-outposts'
|
173
|
+
Aws::S3::OutpostAccessPointARN.new(arn.to_h)
|
174
|
+
when 's3-object-lambda'
|
175
|
+
Aws::S3::ObjectLambdaARN.new(arn.to_h)
|
176
|
+
else
|
177
|
+
raise ArgumentError,
|
178
|
+
'Only Access Point, Outposts, and Object Lambdas ARNs '\
|
179
|
+
'are currently supported.'
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
145
183
|
def resolve_s3_use_arn_region(cfg)
|
146
184
|
value = ENV['AWS_S3_USE_ARN_REGION'] ||
|
147
185
|
Aws.shared_config.s3_use_arn_region(profile: cfg.profile) ||
|
@@ -157,8 +195,22 @@ be made. Set to `false` to use the client's region instead.
|
|
157
195
|
value
|
158
196
|
end
|
159
197
|
|
160
|
-
|
161
|
-
|
198
|
+
def resolve_s3_disable_multiregion_access_points(cfg)
|
199
|
+
value = ENV['AWS_S3_DISABLE_MULTIREGION_ACCESS_POINTS'] ||
|
200
|
+
Aws.shared_config.s3_disable_multiregion_access_points(profile: cfg.profile) ||
|
201
|
+
'false'
|
202
|
+
value = Aws::Util.str_2_bool(value)
|
203
|
+
# Raise if provided value is not true or false
|
204
|
+
if value.nil?
|
205
|
+
raise ArgumentError,
|
206
|
+
'Must provide either `true` or `false` for '\
|
207
|
+
's3_use_arn_region profile option or for '\
|
208
|
+
"ENV['AWS_S3_USE_ARN_REGION']"
|
209
|
+
end
|
210
|
+
value
|
211
|
+
end
|
212
|
+
|
213
|
+
# Remove ARN from the path because we've already set the new host
|
162
214
|
def url_path(path, arn)
|
163
215
|
path = path.sub("/#{Seahorse::Util.uri_escape(arn.to_s)}", '')
|
164
216
|
.sub("/#{arn}", '')
|
@@ -167,34 +219,31 @@ be made. Set to `false` to use the client's region instead.
|
|
167
219
|
end
|
168
220
|
|
169
221
|
def validate_region_config!(arn, region, use_arn_region)
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
(region == 's3-external-1' || region == 'aws-global')
|
176
|
-
if !fips && arn.region.include?('fips')
|
177
|
-
raise ArgumentError,
|
178
|
-
'FIPS region ARNs are not supported for this type of ARN.'
|
179
|
-
end
|
180
|
-
|
181
|
-
if !fips && !use_arn_region && region.include?('fips')
|
182
|
-
raise ArgumentError,
|
183
|
-
'FIPS client regions are not supported for this type of '\
|
184
|
-
'ARN without `:s3_use_arn_region`.'
|
222
|
+
if ['s3-external-1', 'aws-global'].include?(region)
|
223
|
+
# These "regions" are not regional endpoints
|
224
|
+
unless use_arn_region
|
225
|
+
raise Aws::Errors::InvalidARNRegionError,
|
226
|
+
'Configured client region is not a regional endpoint.'
|
185
227
|
end
|
186
|
-
|
187
|
-
#
|
188
|
-
|
189
|
-
region = region.gsub('fips-', '').gsub('-fips', '')
|
190
|
-
end
|
191
|
-
if use_arn_region &&
|
192
|
-
!Aws::Partitions.partition(arn.partition).region?(region)
|
228
|
+
# These "regions" are in the AWS partition
|
229
|
+
# Cannot use ARN region unless it's the same partition
|
230
|
+
unless arn.partition == 'aws'
|
193
231
|
raise Aws::Errors::InvalidARNPartitionError
|
194
232
|
end
|
195
|
-
|
196
|
-
|
197
|
-
|
233
|
+
else
|
234
|
+
# use_arn_region does not apply to MRAP (global) arns
|
235
|
+
unless arn.region.empty?
|
236
|
+
# Raise if the ARN and client regions are in different partitions
|
237
|
+
if use_arn_region &&
|
238
|
+
!Aws::Partitions.partition(arn.partition).region?(region)
|
239
|
+
raise Aws::Errors::InvalidARNPartitionError
|
240
|
+
end
|
241
|
+
|
242
|
+
# Raise if regions mismatch
|
243
|
+
# Either when it's a fips client or not using the ARN region
|
244
|
+
if !use_arn_region && region != arn.region
|
245
|
+
raise Aws::Errors::InvalidARNRegionError
|
246
|
+
end
|
198
247
|
end
|
199
248
|
end
|
200
249
|
end
|
@@ -5,18 +5,9 @@ module Aws
|
|
5
5
|
module Plugins
|
6
6
|
# @api private
|
7
7
|
class Dualstack < Seahorse::Client::Plugin
|
8
|
-
|
9
|
-
option(:use_dualstack_endpoint,
|
10
|
-
default: false,
|
11
|
-
doc_type: 'Boolean',
|
12
|
-
docstring: <<-DOCS)
|
13
|
-
When set to `true`, IPv6-compatible bucket endpoints will be used
|
14
|
-
for all operations.
|
15
|
-
DOCS
|
16
|
-
|
17
8
|
def add_handlers(handlers, config)
|
18
9
|
handlers.add(OptionHandler, step: :initialize)
|
19
|
-
handlers.add(DualstackHandler, step: :build, priority:
|
10
|
+
handlers.add(DualstackHandler, step: :build, priority: 49)
|
20
11
|
end
|
21
12
|
|
22
13
|
# @api private
|
@@ -40,38 +31,41 @@ for all operations.
|
|
40
31
|
# @api private
|
41
32
|
class DualstackHandler < Seahorse::Client::Handler
|
42
33
|
def call(context)
|
43
|
-
if
|
34
|
+
# only rewrite the endpoint if it's not a custom endpoint
|
35
|
+
# accelerate/ARN already handle dualstack cases, so ignore these
|
36
|
+
# check to see if dualstack is on but configured off via operation
|
37
|
+
if context.config.regional_endpoint &&
|
38
|
+
use_dualstack_endpoint?(context)
|
44
39
|
apply_dualstack_endpoint(context)
|
45
40
|
end
|
46
41
|
@handler.call(context)
|
47
42
|
end
|
48
43
|
|
49
44
|
private
|
50
|
-
def apply_dualstack_endpoint(context)
|
51
|
-
bucket_name = context.params[:bucket]
|
52
|
-
region = context.config.region
|
53
|
-
dns_suffix = Aws::Partitions::EndpointProvider.dns_suffix_for(region)
|
54
45
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
46
|
+
def apply_dualstack_endpoint(context)
|
47
|
+
new_endpoint = Aws::Partitions::EndpointProvider.resolve(
|
48
|
+
context.config.region,
|
49
|
+
's3',
|
50
|
+
'regional',
|
51
|
+
{
|
52
|
+
dualstack: context[:use_dualstack_endpoint],
|
53
|
+
fips: context.config.use_fips_endpoint
|
54
|
+
}
|
55
|
+
)
|
60
56
|
endpoint = URI.parse(context.http_request.endpoint.to_s)
|
61
|
-
endpoint.
|
62
|
-
|
63
|
-
endpoint.host = host
|
64
|
-
context.http_request.endpoint = endpoint.to_s
|
65
|
-
end
|
66
|
-
|
67
|
-
def use_bucket_dns?(bucket_name, context)
|
68
|
-
ssl = context.http_request.endpoint.scheme == "https"
|
69
|
-
bucket_name && BucketDns.dns_compatible?(bucket_name, ssl) &&
|
70
|
-
!context.config.force_path_style
|
57
|
+
endpoint.host = URI.parse(new_endpoint).host
|
58
|
+
context.http_request.endpoint = endpoint
|
71
59
|
end
|
72
60
|
|
73
61
|
def use_dualstack_endpoint?(context)
|
74
|
-
|
62
|
+
# case when dualstack is turned off via operation
|
63
|
+
(context[:use_dualstack_endpoint] ||
|
64
|
+
context.config.use_dualstack_endpoint) &&
|
65
|
+
# accelerate plugin already applies dualstack
|
66
|
+
!context[:use_accelerate_endpoint] &&
|
67
|
+
# arns handle dualstack
|
68
|
+
!context.metadata[:s3_arn]
|
75
69
|
end
|
76
70
|
end
|
77
71
|
|
@@ -11,7 +11,7 @@ module Aws
|
|
11
11
|
@handler.call(context).on(200) do |response|
|
12
12
|
response.data = S3::Types::GetBucketLocationOutput.new
|
13
13
|
xml = context.http_response.body_contents
|
14
|
-
matches = xml.match(
|
14
|
+
matches = xml.match(/<LocationConstraint.*?>(.+?)<\/LocationConstraint>/)
|
15
15
|
response.data[:location_constraint] = matches ? matches[1] : ''
|
16
16
|
end
|
17
17
|
end
|
@@ -10,14 +10,15 @@ module Aws
|
|
10
10
|
default: 'legacy',
|
11
11
|
doc_type: String,
|
12
12
|
docstring: <<-DOCS) do |cfg|
|
13
|
-
|
14
|
-
|
13
|
+
Pass in `regional` to enable the `us-east-1` regional endpoint.
|
14
|
+
Defaults to `legacy` mode which uses the global endpoint.
|
15
15
|
DOCS
|
16
16
|
resolve_iad_regional_endpoint(cfg)
|
17
17
|
end
|
18
18
|
|
19
19
|
def add_handlers(handlers, config)
|
20
|
-
|
20
|
+
# only modify non-custom endpoints
|
21
|
+
if config.regional_endpoint && config.region == 'us-east-1'
|
21
22
|
handlers.add(Handler)
|
22
23
|
end
|
23
24
|
end
|
@@ -26,14 +27,14 @@ region. Defaults to `legacy` mode using global endpoint.
|
|
26
27
|
class Handler < Seahorse::Client::Handler
|
27
28
|
|
28
29
|
def call(context)
|
29
|
-
#
|
30
|
-
|
30
|
+
# WriteGetObjectResponse does not have a global endpoint
|
31
|
+
# ARNs are regionalized, so don't touch those either.
|
32
|
+
if context.operation.name != 'WriteGetObjectResponse' &&
|
33
|
+
context.config.s3_us_east_1_regional_endpoint == 'legacy' &&
|
34
|
+
!context.metadata[:s3_arn]
|
31
35
|
host = context.http_request.endpoint.host
|
32
|
-
|
33
|
-
|
34
|
-
legacy_host = IADRegionalEndpoint.legacy_host(host)
|
35
|
-
context.http_request.endpoint.host = legacy_host
|
36
|
-
end
|
36
|
+
legacy_host = IADRegionalEndpoint.legacy_host(host)
|
37
|
+
context.http_request.endpoint.host = legacy_host
|
37
38
|
end
|
38
39
|
@handler.call(context)
|
39
40
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Aws
|
4
|
+
module S3
|
5
|
+
module Plugins
|
6
|
+
# WriteGetObjectResponse is called from Lambda after a data transform.
|
7
|
+
# If there is no custom endpoint, we change the endpoint from s3 to
|
8
|
+
# s3-object-lambda just for this operation.
|
9
|
+
class ObjectLambdaEndpoint < Seahorse::Client::Plugin
|
10
|
+
class Handler < Seahorse::Client::Handler
|
11
|
+
def call(context)
|
12
|
+
if context.config.regional_endpoint
|
13
|
+
host = context.http_request.endpoint.host
|
14
|
+
host = host.sub('s3.', 's3-object-lambda.')
|
15
|
+
context.http_request.endpoint.host = host
|
16
|
+
end
|
17
|
+
@handler.call(context)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
handler(Handler, operations: [:write_get_object_response])
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -22,7 +22,9 @@ module Aws
|
|
22
22
|
# S3 removes core's signature_v4 plugin that checks for this
|
23
23
|
raise Aws::Errors::MissingRegionError if cfg.region.nil?
|
24
24
|
|
25
|
-
Aws::Partitions::EndpointProvider.signing_region(
|
25
|
+
Aws::Partitions::EndpointProvider.signing_region(
|
26
|
+
cfg.region, 's3'
|
27
|
+
)
|
26
28
|
end
|
27
29
|
|
28
30
|
def add_handlers(handlers, cfg)
|
@@ -74,9 +76,23 @@ module Aws
|
|
74
76
|
credentials: context.config.credentials
|
75
77
|
)
|
76
78
|
elsif (arn = context.metadata[:s3_arn])
|
79
|
+
if arn[:arn].is_a?(MultiRegionAccessPointARN)
|
80
|
+
signing_region = '*'
|
81
|
+
signing_algorithm = :sigv4a
|
82
|
+
else
|
83
|
+
signing_region = arn[:resolved_region]
|
84
|
+
signing_algorithm = :sigv4
|
85
|
+
end
|
77
86
|
S3Signer.build_v4_signer(
|
78
87
|
service: arn[:arn].service,
|
79
|
-
|
88
|
+
signing_algorithm: signing_algorithm,
|
89
|
+
region: signing_region,
|
90
|
+
credentials: context.config.credentials
|
91
|
+
)
|
92
|
+
elsif context.operation.name == 'WriteGetObjectResponse'
|
93
|
+
S3Signer.build_v4_signer(
|
94
|
+
service: 's3-object-lambda',
|
95
|
+
region: context.config.sigv4_region,
|
80
96
|
credentials: context.config.credentials
|
81
97
|
)
|
82
98
|
else
|
@@ -148,7 +164,12 @@ module Aws
|
|
148
164
|
|
149
165
|
def custom_endpoint?(resp)
|
150
166
|
resolved_suffix = Aws::Partitions::EndpointProvider.dns_suffix_for(
|
151
|
-
resp.context.config.region
|
167
|
+
resp.context.config.region,
|
168
|
+
's3',
|
169
|
+
{
|
170
|
+
dualstack: resp.context[:use_dualstack_endpoint],
|
171
|
+
fips: resp.context.config.use_fips_endpoint
|
172
|
+
}
|
152
173
|
)
|
153
174
|
!resp.context.http_request.endpoint.hostname.include?(resolved_suffix)
|
154
175
|
end
|
@@ -210,6 +231,7 @@ module Aws
|
|
210
231
|
service: options[:service],
|
211
232
|
region: options[:region],
|
212
233
|
credentials_provider: options[:credentials],
|
234
|
+
signing_algorithm: options.fetch(:signing_algorithm, :sigv4),
|
213
235
|
uri_escape_path: false,
|
214
236
|
unsigned_headers: ['content-length', 'x-amzn-trace-id']
|
215
237
|
)
|
@@ -219,12 +241,20 @@ module Aws
|
|
219
241
|
# Otherwise it will retry with the ARN as the bucket name.
|
220
242
|
def new_hostname(context, region)
|
221
243
|
uri = URI.parse(
|
222
|
-
Aws::Partitions::EndpointProvider.resolve(
|
244
|
+
Aws::Partitions::EndpointProvider.resolve(
|
245
|
+
region, 's3', 'regional',
|
246
|
+
{
|
247
|
+
dualstack: context[:use_dualstack_endpoint],
|
248
|
+
fips: context.config.use_fips_endpoint
|
249
|
+
}
|
250
|
+
)
|
223
251
|
)
|
224
252
|
|
225
253
|
if (arn = context.metadata[:s3_arn])
|
226
254
|
# Retry with the response region and not the ARN resolved one
|
227
|
-
ARN.resolve_url!(
|
255
|
+
ARN.resolve_url!(
|
256
|
+
uri, arn[:arn], region, arn[:fips], arn[:dualstack]
|
257
|
+
).host
|
228
258
|
else
|
229
259
|
"#{context.params[:bucket]}.#{uri.host}"
|
230
260
|
end
|
data/lib/aws-sdk-s3/presigner.rb
CHANGED
@@ -58,8 +58,7 @@ module Aws
|
|
58
58
|
# is returned instead of the default HTTPS URL.
|
59
59
|
#
|
60
60
|
# @option params [Boolean] :virtual_host (false) When `true`, the
|
61
|
-
# bucket name will be used as the hostname.
|
62
|
-
# the returned URL to be 'http' and not 'https'.
|
61
|
+
# bucket name will be used as the hostname.
|
63
62
|
#
|
64
63
|
# @option params [Boolean] :use_accelerate_endpoint (false) When `true`,
|
65
64
|
# Presigner will attempt to use accelerated endpoint.
|
@@ -139,6 +138,7 @@ module Aws
|
|
139
138
|
|
140
139
|
req = @client.build_request(method, params)
|
141
140
|
use_bucket_as_hostname(req) if virtual_host
|
141
|
+
handle_presigned_url_context(req)
|
142
142
|
|
143
143
|
x_amz_headers = sign_but_dont_send(
|
144
144
|
req, expires_in, scheme, time, unsigned_headers, hoist
|
@@ -184,6 +184,17 @@ module Aws
|
|
184
184
|
end
|
185
185
|
end
|
186
186
|
|
187
|
+
# Used for excluding presigned_urls from API request count.
|
188
|
+
#
|
189
|
+
# Store context information as early as possible, to allow
|
190
|
+
# handlers to perform decisions based on this flag if need.
|
191
|
+
def handle_presigned_url_context(req)
|
192
|
+
req.handle(step: :initialize, priority: 98) do |context|
|
193
|
+
context[:presigned_url] = true
|
194
|
+
@handler.call(context)
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
187
198
|
# @param [Seahorse::Client::Request] req
|
188
199
|
def sign_but_dont_send(
|
189
200
|
req, expires_in, scheme, time, unsigned_headers, hoist = true
|
@@ -220,17 +231,23 @@ module Aws
|
|
220
231
|
end
|
221
232
|
http_req.endpoint.query = query.join('&') unless query.empty?
|
222
233
|
|
234
|
+
signing_algorithm = :sigv4
|
235
|
+
|
223
236
|
# If it's an ARN, get the resolved region and service
|
224
237
|
if (arn = context.metadata[:s3_arn])
|
225
238
|
region = arn[:resolved_region]
|
226
239
|
service = arn[:arn].service
|
240
|
+
region = arn[:arn].is_a?(MultiRegionAccessPointARN) ? '*': arn[:resolved_region]
|
241
|
+
signing_algorithm = arn[:arn].is_a?(MultiRegionAccessPointARN) ? :sigv4a : :sigv4
|
227
242
|
end
|
228
243
|
|
229
244
|
signer = Aws::Sigv4::Signer.new(
|
230
245
|
service: service || 's3',
|
231
246
|
region: region || context.config.region,
|
247
|
+
signing_algorithm: signing_algorithm,
|
232
248
|
credentials_provider: context.config.credentials,
|
233
249
|
unsigned_headers: unsigned_headers,
|
250
|
+
apply_checksum_header: false,
|
234
251
|
uri_escape_path: false
|
235
252
|
)
|
236
253
|
|
@@ -243,9 +260,6 @@ module Aws
|
|
243
260
|
time: time
|
244
261
|
).to_s
|
245
262
|
|
246
|
-
# Used for excluding presigned_urls from API request count
|
247
|
-
context[:presigned_url] = true
|
248
|
-
|
249
263
|
Seahorse::Client::Response.new(context: context, data: url)
|
250
264
|
end
|
251
265
|
# Return the headers
|
data/lib/aws-sdk-s3/resource.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# WARNING ABOUT GENERATED CODE
|
4
4
|
#
|
5
5
|
# This file is generated. See the contributing guide for more information:
|
6
|
-
# https://github.com/aws/aws-sdk-ruby/blob/
|
6
|
+
# https://github.com/aws/aws-sdk-ruby/blob/version-3/CONTRIBUTING.md
|
7
7
|
#
|
8
8
|
# WARNING ABOUT GENERATED CODE
|
9
9
|
|
@@ -65,8 +65,10 @@ module Aws::S3
|
|
65
65
|
# @option options [String] :grant_read_acp
|
66
66
|
# Allows grantee to read the bucket ACL.
|
67
67
|
# @option options [String] :grant_write
|
68
|
-
# Allows grantee to create
|
69
|
-
#
|
68
|
+
# Allows grantee to create new objects in the bucket.
|
69
|
+
#
|
70
|
+
# For the bucket and object owners of existing objects, also allows
|
71
|
+
# deletions and overwrites of those objects.
|
70
72
|
# @option options [String] :grant_write_acp
|
71
73
|
# Allows grantee to write the ACL for the applicable bucket.
|
72
74
|
# @option options [Boolean] :object_lock_enabled_for_bucket
|