aws-sdk-s3 1.48.0 → 1.60.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 (39) hide show
  1. checksums.yaml +4 -4
  2. data/lib/aws-sdk-s3/bucket.rb +183 -54
  3. data/lib/aws-sdk-s3/bucket_acl.rb +9 -1
  4. data/lib/aws-sdk-s3/bucket_cors.rb +18 -1
  5. data/lib/aws-sdk-s3/bucket_lifecycle.rb +2 -1
  6. data/lib/aws-sdk-s3/bucket_lifecycle_configuration.rb +3 -1
  7. data/lib/aws-sdk-s3/bucket_logging.rb +11 -1
  8. data/lib/aws-sdk-s3/bucket_notification.rb +7 -3
  9. data/lib/aws-sdk-s3/bucket_policy.rb +2 -0
  10. data/lib/aws-sdk-s3/bucket_request_payment.rb +10 -0
  11. data/lib/aws-sdk-s3/bucket_tagging.rb +10 -1
  12. data/lib/aws-sdk-s3/bucket_versioning.rb +26 -0
  13. data/lib/aws-sdk-s3/bucket_website.rb +15 -4
  14. data/lib/aws-sdk-s3/client.rb +5133 -519
  15. data/lib/aws-sdk-s3/client_api.rb +33 -0
  16. data/lib/aws-sdk-s3/customizations/bucket.rb +44 -13
  17. data/lib/aws-sdk-s3/customizations/object.rb +65 -43
  18. data/lib/aws-sdk-s3/encryption/client.rb +4 -0
  19. data/lib/aws-sdk-s3/file_part.rb +9 -6
  20. data/lib/aws-sdk-s3/file_uploader.rb +13 -12
  21. data/lib/aws-sdk-s3/multipart_file_uploader.rb +14 -11
  22. data/lib/aws-sdk-s3/multipart_upload.rb +31 -16
  23. data/lib/aws-sdk-s3/multipart_upload_part.rb +38 -29
  24. data/lib/aws-sdk-s3/object.rb +330 -129
  25. data/lib/aws-sdk-s3/object_acl.rb +25 -7
  26. data/lib/aws-sdk-s3/object_summary.rb +243 -117
  27. data/lib/aws-sdk-s3/object_version.rb +67 -46
  28. data/lib/aws-sdk-s3/plugins/bucket_arn.rb +211 -0
  29. data/lib/aws-sdk-s3/plugins/bucket_dns.rb +7 -7
  30. data/lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb +23 -3
  31. data/lib/aws-sdk-s3/plugins/iad_regional_endpoint.rb +59 -0
  32. data/lib/aws-sdk-s3/plugins/md5s.rb +3 -4
  33. data/lib/aws-sdk-s3/plugins/s3_signer.rb +16 -6
  34. data/lib/aws-sdk-s3/presigned_post.rb +4 -0
  35. data/lib/aws-sdk-s3/presigner.rb +6 -2
  36. data/lib/aws-sdk-s3/resource.rb +4 -2
  37. data/lib/aws-sdk-s3/types.rb +3027 -635
  38. data/lib/aws-sdk-s3.rb +1 -1
  39. metadata +6 -4
@@ -27,6 +27,7 @@ module Aws::S3
27
27
  @id = extract_id(args, options)
28
28
  @data = options.delete(:data)
29
29
  @client = options.delete(:client) || Client.new(options)
30
+ @waiter_block_warned = false
30
31
  end
31
32
 
32
33
  # @!group Read-Only Attributes
@@ -46,7 +47,7 @@ module Aws::S3
46
47
  @id
47
48
  end
48
49
 
49
-
50
+ # The entity tag is an MD5 hash of that version of the object.
50
51
  # @return [String]
51
52
  def etag
52
53
  data[:etag]
@@ -89,7 +90,7 @@ module Aws::S3
89
90
  data[:last_modified]
90
91
  end
91
92
 
92
-
93
+ # Specifies the owner of the object.
93
94
  # @return [Types::Owner]
94
95
  def owner
95
96
  data[:owner]
@@ -233,14 +234,20 @@ module Aws::S3
233
234
  # @option options [String] :mfa
234
235
  # The concatenation of the authentication device's serial number, a
235
236
  # space, and the value that is displayed on your authentication device.
237
+ # Required to permanently delete a versioned object if versioning is
238
+ # configured with MFA delete enabled.
236
239
  # @option options [String] :request_payer
237
- # Confirms that the requester knows that she or he will be charged for
238
- # the request. Bucket owners need not specify this parameter in their
239
- # requests. Documentation on downloading objects from requester pays
240
- # buckets can be found at
241
- # http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
240
+ # Confirms that the requester knows that they will be charged for the
241
+ # request. Bucket owners need not specify this parameter in their
242
+ # requests. For information about downloading objects from requester
243
+ # pays buckets, see [Downloading Objects in Requestor Pays Buckets][1]
244
+ # in the *Amazon S3 Developer Guide*.
245
+ #
246
+ #
247
+ #
248
+ # [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
242
249
  # @option options [Boolean] :bypass_governance_retention
243
- # Indicates whether Amazon S3 object lock should bypass governance-mode
250
+ # Indicates whether S3 Object Lock should bypass Governance-mode
244
251
  # restrictions to process this operation.
245
252
  # @return [Types::DeleteObjectOutput]
246
253
  def delete(options = {})
@@ -288,39 +295,43 @@ module Aws::S3
288
295
  # time, otherwise return a 412 (precondition failed).
289
296
  # @option options [String] :range
290
297
  # Downloads the specified range bytes of an object. For more information
291
- # about the HTTP Range header, go to
292
- # http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.
298
+ # about the HTTP Range header, see
299
+ # [http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35]().
293
300
  # @option options [String] :response_cache_control
294
- # Sets the Cache-Control header of the response.
301
+ # Sets the `Cache-Control` header of the response.
295
302
  # @option options [String] :response_content_disposition
296
- # Sets the Content-Disposition header of the response
303
+ # Sets the `Content-Disposition` header of the response
297
304
  # @option options [String] :response_content_encoding
298
- # Sets the Content-Encoding header of the response.
305
+ # Sets the `Content-Encoding` header of the response.
299
306
  # @option options [String] :response_content_language
300
- # Sets the Content-Language header of the response.
307
+ # Sets the `Content-Language` header of the response.
301
308
  # @option options [String] :response_content_type
302
- # Sets the Content-Type header of the response.
309
+ # Sets the `Content-Type` header of the response.
303
310
  # @option options [Time,DateTime,Date,Integer,String] :response_expires
304
- # Sets the Expires header of the response.
311
+ # Sets the `Expires` header of the response.
305
312
  # @option options [String] :sse_customer_algorithm
306
- # Specifies the algorithm to use to when encrypting the object (e.g.,
307
- # AES256).
313
+ # Specifies the algorithm to use to when encrypting the object (for
314
+ # example, AES256).
308
315
  # @option options [String] :sse_customer_key
309
316
  # Specifies the customer-provided encryption key for Amazon S3 to use in
310
317
  # encrypting data. This value is used to store the object and then it is
311
- # discarded; Amazon does not store the encryption key. The key must be
312
- # appropriate for use with the algorithm specified in the
313
- # x-amz-server-side​-encryption​-customer-algorithm header.
318
+ # discarded; Amazon S3 does not store the encryption key. The key must
319
+ # be appropriate for use with the algorithm specified in the
320
+ # `x-amz-server-side​-encryption​-customer-algorithm` header.
314
321
  # @option options [String] :sse_customer_key_md5
315
322
  # Specifies the 128-bit MD5 digest of the encryption key according to
316
323
  # RFC 1321. Amazon S3 uses this header for a message integrity check to
317
- # ensure the encryption key was transmitted without error.
324
+ # ensure that the encryption key was transmitted without error.
318
325
  # @option options [String] :request_payer
319
- # Confirms that the requester knows that she or he will be charged for
320
- # the request. Bucket owners need not specify this parameter in their
321
- # requests. Documentation on downloading objects from requester pays
322
- # buckets can be found at
323
- # http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
326
+ # Confirms that the requester knows that they will be charged for the
327
+ # request. Bucket owners need not specify this parameter in their
328
+ # requests. For information about downloading objects from requester
329
+ # pays buckets, see [Downloading Objects in Requestor Pays Buckets][1]
330
+ # in the *Amazon S3 Developer Guide*.
331
+ #
332
+ #
333
+ #
334
+ # [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
324
335
  # @option options [Integer] :part_number
325
336
  # Part number of the object being read. This is a positive integer
326
337
  # between 1 and 10,000. Effectively performs a 'ranged' GET request
@@ -366,27 +377,31 @@ module Aws::S3
366
377
  # time, otherwise return a 412 (precondition failed).
367
378
  # @option options [String] :range
368
379
  # Downloads the specified range bytes of an object. For more information
369
- # about the HTTP Range header, go to
370
- # http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.
380
+ # about the HTTP Range header, see
381
+ # [http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35]().
371
382
  # @option options [String] :sse_customer_algorithm
372
- # Specifies the algorithm to use to when encrypting the object (e.g.,
373
- # AES256).
383
+ # Specifies the algorithm to use to when encrypting the object (for
384
+ # example, AES256).
374
385
  # @option options [String] :sse_customer_key
375
386
  # Specifies the customer-provided encryption key for Amazon S3 to use in
376
387
  # encrypting data. This value is used to store the object and then it is
377
- # discarded; Amazon does not store the encryption key. The key must be
378
- # appropriate for use with the algorithm specified in the
379
- # x-amz-server-side​-encryption​-customer-algorithm header.
388
+ # discarded; Amazon S3 does not store the encryption key. The key must
389
+ # be appropriate for use with the algorithm specified in the
390
+ # `x-amz-server-side​-encryption​-customer-algorithm` header.
380
391
  # @option options [String] :sse_customer_key_md5
381
392
  # Specifies the 128-bit MD5 digest of the encryption key according to
382
393
  # RFC 1321. Amazon S3 uses this header for a message integrity check to
383
- # ensure the encryption key was transmitted without error.
394
+ # ensure that the encryption key was transmitted without error.
384
395
  # @option options [String] :request_payer
385
- # Confirms that the requester knows that she or he will be charged for
386
- # the request. Bucket owners need not specify this parameter in their
387
- # requests. Documentation on downloading objects from requester pays
388
- # buckets can be found at
389
- # http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
396
+ # Confirms that the requester knows that they will be charged for the
397
+ # request. Bucket owners need not specify this parameter in their
398
+ # requests. For information about downloading objects from requester
399
+ # pays buckets, see [Downloading Objects in Requestor Pays Buckets][1]
400
+ # in the *Amazon S3 Developer Guide*.
401
+ #
402
+ #
403
+ #
404
+ # [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
390
405
  # @option options [Integer] :part_number
391
406
  # Part number of the object being read. This is a positive integer
392
407
  # between 1 and 10,000. Effectively performs a 'ranged' HEAD request
@@ -475,15 +490,21 @@ module Aws::S3
475
490
  # @option options [String] :mfa
476
491
  # The concatenation of the authentication device's serial number, a
477
492
  # space, and the value that is displayed on your authentication device.
493
+ # Required to permanently delete a versioned object if versioning is
494
+ # configured with MFA delete enabled.
478
495
  # @option options [String] :request_payer
479
- # Confirms that the requester knows that she or he will be charged for
480
- # the request. Bucket owners need not specify this parameter in their
481
- # requests. Documentation on downloading objects from requester pays
482
- # buckets can be found at
483
- # http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
496
+ # Confirms that the requester knows that they will be charged for the
497
+ # request. Bucket owners need not specify this parameter in their
498
+ # requests. For information about downloading objects from requester
499
+ # pays buckets, see [Downloading Objects in Requestor Pays Buckets][1]
500
+ # in the *Amazon S3 Developer Guide*.
501
+ #
502
+ #
503
+ #
504
+ # [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
484
505
  # @option options [Boolean] :bypass_governance_retention
485
506
  # Specifies whether you want to delete this object even if it has a
486
- # Governance-type object lock in place. You must have sufficient
507
+ # Governance-type Object Lock in place. You must have sufficient
487
508
  # permissions to perform this operation.
488
509
  # @return [void]
489
510
  def batch_delete!(options = {})
@@ -0,0 +1,211 @@
1
+ module Aws
2
+ module S3
3
+ module Plugins
4
+ # When an accesspoint ARN is provided for :bucket in S3 operations, this
5
+ # plugin resolves the request endpoint from the ARN when possible.
6
+ class BucketARN < Seahorse::Client::Plugin
7
+ option(
8
+ :s3_use_arn_region,
9
+ default: true,
10
+ doc_type: 'Boolean',
11
+ docstring: <<-DOCS) do |cfg|
12
+ By default, the SDK will use the S3 ARN region, and cross-region
13
+ requests could be made. Set to `false` to not use the region from
14
+ the S3 ARN.
15
+ DOCS
16
+ resolve_s3_use_arn_region(cfg)
17
+ end
18
+
19
+ def add_handlers(handlers, _config)
20
+ handlers.add(Handler)
21
+ end
22
+
23
+ # @api private
24
+ class Handler < Seahorse::Client::Handler
25
+ def call(context)
26
+ bucket_member = _bucket_member(context.operation.input.shape)
27
+ if bucket_member && (bucket = context.params[bucket_member])
28
+ _resolved_bucket, _resolved_region, arn = BucketARN.resolve_arn!(
29
+ bucket,
30
+ context.config.region,
31
+ context.config.s3_use_arn_region
32
+ )
33
+ if arn
34
+ if arn.resource.start_with?('accesspoint')
35
+ validate_config!(context.config)
36
+ end
37
+
38
+ dualstack = extract_dualstack_config!(context)
39
+
40
+ BucketARN.resolve_url!(
41
+ context.http_request.endpoint,
42
+ arn,
43
+ dualstack
44
+ )
45
+ end
46
+ end
47
+ @handler.call(context)
48
+ end
49
+
50
+ private
51
+
52
+ def _bucket_member(input)
53
+ input.members.each do |member, ref|
54
+ return member if ref.shape.name == 'BucketName'
55
+ end
56
+ nil
57
+ end
58
+
59
+ # other plugins use dualstack so disable it when we're done
60
+ def extract_dualstack_config!(context)
61
+ dualstack = context[:use_dualstack_endpoint]
62
+ context[:use_dualstack_endpoint] = false if dualstack
63
+ dualstack
64
+ end
65
+
66
+ def validate_config!(config)
67
+ unless config.regional_endpoint
68
+ raise ArgumentError,
69
+ 'Cannot provide both an accesspoint ARN and :endpoint.'
70
+ end
71
+
72
+ if config.use_accelerate_endpoint
73
+ raise ArgumentError,
74
+ 'Cannot provide both an accesspoint ARN and setting '\
75
+ ':use_accelerate_endpoint to true.'
76
+ end
77
+
78
+ if config.force_path_style
79
+ raise ArgumentError,
80
+ 'Cannot provide both an accesspoint ARN and setting '\
81
+ ':force_path_style to true.'
82
+ end
83
+ end
84
+ end
85
+
86
+ class << self
87
+
88
+ # @api private
89
+ def resolve_arn!(bucket_name, region, s3_use_arn_region)
90
+ if Aws::ARNParser.arn?(bucket_name)
91
+ arn = Aws::ARNParser.parse(bucket_name)
92
+ validate_s3_arn!(arn)
93
+ validate_region!(arn, region, s3_use_arn_region)
94
+ if arn.resource.start_with?('accesspoint')
95
+ region = arn.region if s3_use_arn_region
96
+ [bucket_name, region, arn]
97
+ else
98
+ raise ArgumentError,
99
+ 'Only accesspoint type ARNs are currently supported.'
100
+ end
101
+ else
102
+ [bucket_name, region]
103
+ end
104
+ end
105
+
106
+ # @api private
107
+ def resolve_url!(url, arn, dualstack = false)
108
+ if arn.resource.start_with?('accesspoint')
109
+ url.host = accesspoint_arn_host(arn, dualstack)
110
+ else
111
+ raise ArgumentError,
112
+ 'Only accesspoint type ARNs are currently supported.'
113
+ end
114
+ url.path = url_path(url.path, arn)
115
+ url
116
+ end
117
+
118
+ private
119
+
120
+ def accesspoint_arn_host(arn, dualstack)
121
+ _resource_type, resource_name = parse_resource(arn.resource)
122
+ accesspoint = "#{resource_name}-#{arn.account_id}"
123
+ accesspoint << '.s3-accesspoint'
124
+ accesspoint << '.dualstack' if dualstack
125
+ sfx = Aws::Partitions::EndpointProvider.dns_suffix_for(arn.region)
126
+ accesspoint << ".#{arn.region}.#{sfx}"
127
+ accesspoint
128
+ end
129
+
130
+ def parse_resource(str)
131
+ slash = str.index('/') || str.length
132
+ colon = str.index(':') || str.length
133
+ delimiter = slash < colon ? slash : colon
134
+ if delimiter < str.length
135
+ [str[0..(delimiter - 1)], str[(delimiter + 1)..-1]]
136
+ else
137
+ [nil, str]
138
+ end
139
+ end
140
+
141
+ def resolve_s3_use_arn_region(cfg)
142
+ value = ENV['AWS_S3_USE_ARN_REGION'] ||
143
+ Aws.shared_config.s3_use_arn_region(profile: cfg.profile) ||
144
+ 'true'
145
+
146
+ # Raise if provided value is not true or false
147
+ if value != 'true' && value != 'false'
148
+ raise ArgumentError,
149
+ 'Must provide either `true` or `false` for '\
150
+ 's3_use_arn_region profile option or for '\
151
+ 'ENV[\'AWS_S3_USE_ARN_REGION\']'
152
+ end
153
+
154
+ value == 'true'
155
+ end
156
+
157
+ def url_path(path, arn)
158
+ path = path.sub("/#{Seahorse::Util.uri_escape(arn.to_s)}", '')
159
+ .sub("/#{arn}", '')
160
+ "/#{path}" unless path.match(/^\//)
161
+ path
162
+ end
163
+
164
+ def validate_s3_arn!(arn)
165
+ _resource_type, resource_name = parse_resource(arn.resource)
166
+
167
+ unless arn.service == 's3'
168
+ raise ArgumentError, 'Must provide an S3 ARN.'
169
+ end
170
+
171
+ if arn.region.empty? || arn.account_id.empty?
172
+ raise ArgumentError,
173
+ 'S3 Access Point ARNs must contain both a valid region '\
174
+ ' and a valid account id.'
175
+ end
176
+
177
+ if resource_name.include?(':') || resource_name.include?('/')
178
+ raise ArgumentError,
179
+ 'ARN resource id must be a single value.'
180
+ end
181
+
182
+ unless Plugins::BucketDns.valid_subdomain?(
183
+ "#{resource_name}-#{arn.account_id}"
184
+ )
185
+ raise ArgumentError,
186
+ "#{resource_name}-#{arn.account_id} is not a "\
187
+ 'valid subdomain.'
188
+ end
189
+ end
190
+
191
+ def validate_region!(arn, region, s3_use_arn_region)
192
+ if region.include?('fips')
193
+ raise ArgumentError,
194
+ 'FIPS client regions are currently not supported with '\
195
+ 'accesspoint ARNs.'
196
+ end
197
+
198
+ if s3_use_arn_region &&
199
+ !Aws::Partitions.partition(arn.partition).region?(region)
200
+ raise Aws::Errors::InvalidARNPartitionError
201
+ end
202
+
203
+ if !s3_use_arn_region && region != arn.region
204
+ raise Aws::Errors::InvalidARNRegionError
205
+ end
206
+ end
207
+ end
208
+ end
209
+ end
210
+ end
211
+ end
@@ -38,11 +38,9 @@ request URI and never moved to the host as a sub-domain.
38
38
  def move_dns_compat_bucket_to_subdomain(context)
39
39
  bucket_name = context.params[:bucket]
40
40
  endpoint = context.http_request.endpoint
41
- if
42
- bucket_name &&
43
- BucketDns.dns_compatible?(bucket_name, https?(endpoint)) &&
44
- context.operation_name.to_s != 'get_bucket_location'
45
- then
41
+ if bucket_name &&
42
+ BucketDns.dns_compatible?(bucket_name, https?(endpoint)) &&
43
+ context.operation_name.to_s != 'get_bucket_location'
46
44
  move_bucket_to_subdomain(bucket_name, endpoint)
47
45
  end
48
46
  end
@@ -73,8 +71,10 @@ request URI and never moved to the host as a sub-domain.
73
71
  end
74
72
  end
75
73
 
76
- private
77
-
74
+ # Checks for a valid RFC-3986 host name
75
+ # @see https://tools.ietf.org/html/rfc3986#section-3.2.2
76
+ # @param [String] bucket_name
77
+ # @return [Boolean]
78
78
  def valid_subdomain?(bucket_name)
79
79
  bucket_name.size < 64 &&
80
80
  bucket_name =~ /^[a-z0-9][a-z0-9.-]+[a-z0-9]$/ &&
@@ -5,14 +5,34 @@ module Aws
5
5
  class BucketNameRestrictions < Seahorse::Client::Plugin
6
6
  class Handler < Seahorse::Client::Handler
7
7
 
8
+ # Useful because Aws::S3::Errors::SignatureDoesNotMatch is thrown
9
+ # when passed a bucket with a forward slash. Instead provide a more
10
+ # helpful error. Ideally should not be a plugin?
8
11
  def call(context)
9
- if context.params.key?(:bucket) && context.params[:bucket].include?('/')
10
- msg = ":bucket option must not contain a forward-slash (/)"
11
- raise ArgumentError, msg
12
+ bucket_member = _bucket_member(context.operation.input.shape)
13
+ if bucket_member && (bucket = context.params[bucket_member])
14
+ _resolved_bucket, _resolved_region, arn = BucketARN.resolve_arn!(
15
+ bucket,
16
+ context.config.region,
17
+ context.config.s3_use_arn_region
18
+ )
19
+ if !arn && bucket.include?('/')
20
+ raise ArgumentError,
21
+ 'bucket name must not contain a forward-slash (/)'
22
+ end
12
23
  end
13
24
  @handler.call(context)
14
25
  end
15
26
 
27
+ private
28
+
29
+ def _bucket_member(input)
30
+ input.members.each do |member, ref|
31
+ return member if ref.shape.name == 'BucketName'
32
+ end
33
+ nil
34
+ end
35
+
16
36
  end
17
37
 
18
38
  handler(Handler)
@@ -0,0 +1,59 @@
1
+ module Aws
2
+ module S3
3
+ module Plugins
4
+
5
+ class IADRegionalEndpoint < Seahorse::Client::Plugin
6
+
7
+ option(:s3_us_east_1_regional_endpoint,
8
+ default: 'legacy',
9
+ doc_type: String,
10
+ docstring: <<-DOCS) do |cfg|
11
+ Passing in `regional` to enable regional endpoint for S3's `us-east-1`
12
+ region. Defaults to `legacy` mode using global endpoint.
13
+ DOCS
14
+ resolve_iad_regional_endpoint(cfg)
15
+ end
16
+
17
+ def add_handlers(handlers, config)
18
+ if config.region == 'us-east-1'
19
+ handlers.add(Handler)
20
+ end
21
+ end
22
+
23
+ # @api private
24
+ class Handler < Seahorse::Client::Handler
25
+
26
+ def call(context)
27
+ # keep legacy global endpoint pattern by default
28
+ if context.config.s3_us_east_1_regional_endpoint == 'legacy'
29
+ context.http_request.endpoint.host = IADRegionalEndpoint.legacy_host(
30
+ context.http_request.endpoint.host)
31
+ end
32
+ @handler.call(context)
33
+ end
34
+
35
+ end
36
+
37
+ def self.legacy_host(host)
38
+ host.sub(".us-east-1", '')
39
+ end
40
+
41
+ private
42
+
43
+ def self.resolve_iad_regional_endpoint(cfg)
44
+ mode = ENV['AWS_S3_US_EAST_1_REGIONAL_ENDPOINT'] ||
45
+ Aws.shared_config.s3_us_east_1_regional_endpoint(profile: cfg.profile) ||
46
+ 'legacy'
47
+ unless %w(legacy regional).include?(mode)
48
+ raise ArgumentError, "expected :s3_us_east_1_regional_endpoint or"\
49
+ " ENV['AWS_S3_US_EAST_1_REGIONAL_ENDPOINT'] to be `legacy` or"\
50
+ " `regional`."
51
+ end
52
+ mode
53
+ end
54
+
55
+ end
56
+
57
+ end
58
+ end
59
+ end
@@ -1,5 +1,4 @@
1
1
  require 'openssl'
2
- require 'base64'
3
2
 
4
3
  module Aws
5
4
  module S3
@@ -37,13 +36,13 @@ module Aws
37
36
  # @return [String<MD5>]
38
37
  def md5(value)
39
38
  if (File === value || Tempfile === value) && !value.path.nil? && File.exist?(value.path)
40
- Base64.encode64(OpenSSL::Digest::MD5.file(value).digest).strip
39
+ OpenSSL::Digest::MD5.file(value).base64digest
41
40
  elsif value.respond_to?(:read)
42
41
  md5 = OpenSSL::Digest::MD5.new
43
42
  update_in_chunks(md5, value)
44
- Base64.encode64(md5.digest).strip
43
+ md5.base64digest
45
44
  else
46
- Base64.encode64(OpenSSL::Digest::MD5.digest(value)).strip
45
+ OpenSSL::Digest::MD5.digest(value).base64digest
47
46
  end
48
47
  end
49
48
 
@@ -17,6 +17,8 @@ module Aws
17
17
  end
18
18
 
19
19
  option(:sigv4_region) do |cfg|
20
+ raise Aws::Errors::MissingRegionError if cfg.region.nil?
21
+
20
22
  Aws::Partitions::EndpointProvider.signing_region(cfg.region, 's3')
21
23
  end
22
24
 
@@ -197,15 +199,23 @@ module Aws
197
199
  end
198
200
 
199
201
  def new_hostname(context, region)
200
- bucket = context.params[:bucket]
201
- if region == 'us-east-1'
202
- "#{bucket}.s3.amazonaws.com"
202
+ # Check to see if the bucket is actually an ARN and resolve it
203
+ # Otherwise it will retry with the ARN as the bucket name.
204
+ resolved_bucket, resolved_region, arn = BucketARN.resolve_arn!(
205
+ context.params[:bucket],
206
+ region,
207
+ context.config.s3_use_arn_region
208
+ )
209
+ uri = URI.parse(
210
+ Aws::Partitions::EndpointProvider.resolve(resolved_region, 's3')
211
+ )
212
+
213
+ if arn
214
+ BucketARN.resolve_url!(uri, arn).host
203
215
  else
204
- endpoint = Aws::Partitions::EndpointProvider.resolve(region, 's3')
205
- bucket + '.' + URI.parse(endpoint).host
216
+ resolved_bucket + '.' + uri.host
206
217
  end
207
218
  end
208
-
209
219
  end
210
220
  end
211
221
  end
@@ -585,6 +585,10 @@ module Aws
585
585
  else
586
586
  url.path = '/' + @bucket_name
587
587
  end
588
+ if @bucket_region == 'us-east-1'
589
+ # keep legacy behavior by default
590
+ url.host = Plugins::IADRegionalEndpoint.legacy_host(url.host)
591
+ end
588
592
  url.to_s
589
593
  end
590
594
 
@@ -103,9 +103,13 @@ module Aws
103
103
  def expires_in(params)
104
104
  if (expires_in = params.delete(:expires_in))
105
105
  if expires_in > ONE_WEEK
106
- msg = "expires_in value of #{expires_in} exceeds one-week maximum"
107
- raise ArgumentError, msg
106
+ raise ArgumentError,
107
+ "expires_in value of #{expires_in} exceeds one-week maximum"
108
+ elsif expires_in <= 0
109
+ raise ArgumentError,
110
+ "expires_in value of #{expires_in} cannot be 0 or less"
108
111
  end
112
+
109
113
  expires_in
110
114
  else
111
115
  FIFTEEN_MINUTES
@@ -40,7 +40,9 @@ module Aws::S3
40
40
  # @option options [String] :acl
41
41
  # The canned ACL to apply to the bucket.
42
42
  # @option options [required, String] :bucket
43
+ # The name of the bucket to create.
43
44
  # @option options [Types::CreateBucketConfiguration] :create_bucket_configuration
45
+ # The configuration information for the bucket.
44
46
  # @option options [String] :grant_full_control
45
47
  # Allows grantee the read, write, read ACP, and write ACP permissions on
46
48
  # the bucket.
@@ -54,8 +56,8 @@ module Aws::S3
54
56
  # @option options [String] :grant_write_acp
55
57
  # Allows grantee to write the ACL for the applicable bucket.
56
58
  # @option options [Boolean] :object_lock_enabled_for_bucket
57
- # Specifies whether you want Amazon S3 object lock to be enabled for the
58
- # new bucket.
59
+ # Specifies whether you want S3 Object Lock to be enabled for the new
60
+ # bucket.
59
61
  # @return [Bucket]
60
62
  def create_bucket(options = {})
61
63
  resp = @client.create_bucket(options)