aws-sdk-s3 1.81.0 → 1.83.2
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 +4 -4
- data/lib/aws-sdk-s3.rb +1 -1
- data/lib/aws-sdk-s3/arn/access_point_arn.rb +62 -0
- data/lib/aws-sdk-s3/arn/outpost_access_point_arn.rb +71 -0
- data/lib/aws-sdk-s3/bucket.rb +21 -3
- data/lib/aws-sdk-s3/client.rb +820 -269
- data/lib/aws-sdk-s3/client_api.rb +61 -0
- data/lib/aws-sdk-s3/customizations.rb +1 -1
- data/lib/aws-sdk-s3/customizations/bucket.rb +7 -4
- data/lib/aws-sdk-s3/customizations/object.rb +4 -3
- data/lib/aws-sdk-s3/file_uploader.rb +1 -1
- data/lib/aws-sdk-s3/multipart_upload_part.rb +12 -3
- data/lib/aws-sdk-s3/object.rb +73 -8
- data/lib/aws-sdk-s3/object_acl.rb +8 -0
- data/lib/aws-sdk-s3/object_summary.rb +73 -8
- data/lib/aws-sdk-s3/object_version.rb +5 -1
- data/lib/aws-sdk-s3/plugins/arn.rb +187 -0
- data/lib/aws-sdk-s3/plugins/bucket_dns.rb +0 -2
- data/lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb +1 -1
- data/lib/aws-sdk-s3/plugins/iad_regional_endpoint.rb +7 -2
- data/lib/aws-sdk-s3/plugins/s3_signer.rb +29 -7
- data/lib/aws-sdk-s3/presigner.rb +1 -0
- data/lib/aws-sdk-s3/types.rb +701 -106
- metadata +7 -5
- data/lib/aws-sdk-s3/plugins/bucket_arn.rb +0 -212
|
@@ -295,7 +295,7 @@ module Aws::S3
|
|
|
295
295
|
# metadata_directive: "COPY", # accepts COPY, REPLACE
|
|
296
296
|
# tagging_directive: "COPY", # accepts COPY, REPLACE
|
|
297
297
|
# server_side_encryption: "AES256", # accepts AES256, aws:kms
|
|
298
|
-
# storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE
|
|
298
|
+
# storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, OUTPOSTS
|
|
299
299
|
# website_redirect_location: "WebsiteRedirectLocation",
|
|
300
300
|
# sse_customer_algorithm: "SSECustomerAlgorithm",
|
|
301
301
|
# sse_customer_key: "SSECustomerKey",
|
|
@@ -316,6 +316,8 @@ module Aws::S3
|
|
|
316
316
|
# @param [Hash] options ({})
|
|
317
317
|
# @option options [String] :acl
|
|
318
318
|
# The canned ACL to apply to the object.
|
|
319
|
+
#
|
|
320
|
+
# This action is not supported by Amazon S3 on Outposts.
|
|
319
321
|
# @option options [String] :cache_control
|
|
320
322
|
# Specifies caching behavior along the request/reply chain.
|
|
321
323
|
# @option options [String] :content_disposition
|
|
@@ -355,6 +357,15 @@ module Aws::S3
|
|
|
355
357
|
#
|
|
356
358
|
# </note>
|
|
357
359
|
#
|
|
360
|
+
# Alternatively, for objects accessed through Amazon S3 on Outposts,
|
|
361
|
+
# specify the ARN of the object as accessed in the format
|
|
362
|
+
# `arn:aws:s3-outposts:<Region>:<account-id>:outpost/<outpost-id>/object/<key>`.
|
|
363
|
+
# For example, to copy the object `reports/january.pdf` through
|
|
364
|
+
# outpost `my-outpost` owned by account `123456789012` in Region
|
|
365
|
+
# `us-west-2`, use the URL encoding of
|
|
366
|
+
# `arn:aws:s3-outposts:us-west-2:123456789012:outpost/my-outpost/object/reports/january.pdf`.
|
|
367
|
+
# The value must be URL encoded.
|
|
368
|
+
#
|
|
358
369
|
# To copy a specific version of an object, append
|
|
359
370
|
# `?versionId=<version-id>` to the value (for example,
|
|
360
371
|
# `awsexamplebucket/reports/january.pdf?versionId=QUpfdndhfd8438MNFDN93jdnJFkdmqnh893`).
|
|
@@ -379,12 +390,20 @@ module Aws::S3
|
|
|
379
390
|
# @option options [String] :grant_full_control
|
|
380
391
|
# Gives the grantee READ, READ\_ACP, and WRITE\_ACP permissions on the
|
|
381
392
|
# object.
|
|
393
|
+
#
|
|
394
|
+
# This action is not supported by Amazon S3 on Outposts.
|
|
382
395
|
# @option options [String] :grant_read
|
|
383
396
|
# Allows grantee to read the object data and its metadata.
|
|
397
|
+
#
|
|
398
|
+
# This action is not supported by Amazon S3 on Outposts.
|
|
384
399
|
# @option options [String] :grant_read_acp
|
|
385
400
|
# Allows grantee to read the object ACL.
|
|
401
|
+
#
|
|
402
|
+
# This action is not supported by Amazon S3 on Outposts.
|
|
386
403
|
# @option options [String] :grant_write_acp
|
|
387
404
|
# Allows grantee to write the ACL for the applicable object.
|
|
405
|
+
#
|
|
406
|
+
# This action is not supported by Amazon S3 on Outposts.
|
|
388
407
|
# @option options [Hash<String,String>] :metadata
|
|
389
408
|
# A map of metadata to store with the object in S3.
|
|
390
409
|
# @option options [String] :metadata_directive
|
|
@@ -397,7 +416,16 @@ module Aws::S3
|
|
|
397
416
|
# The server-side encryption algorithm used when storing this object in
|
|
398
417
|
# Amazon S3 (for example, AES256, aws:kms).
|
|
399
418
|
# @option options [String] :storage_class
|
|
400
|
-
#
|
|
419
|
+
# By default, Amazon S3 uses the STANDARD Storage Class to store newly
|
|
420
|
+
# created objects. The STANDARD storage class provides high durability
|
|
421
|
+
# and high availability. Depending on performance needs, you can specify
|
|
422
|
+
# a different Storage Class. Amazon S3 on Outposts only uses the
|
|
423
|
+
# OUTPOSTS Storage Class. For more information, see [Storage Classes][1]
|
|
424
|
+
# in the *Amazon S3 Service Developer Guide*.
|
|
425
|
+
#
|
|
426
|
+
#
|
|
427
|
+
#
|
|
428
|
+
# [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/storage-class-intro.html
|
|
401
429
|
# @option options [String] :website_redirect_location
|
|
402
430
|
# If the bucket is configured as a website, redirects requests for this
|
|
403
431
|
# object to another object in the same bucket or to an external URL.
|
|
@@ -646,7 +674,7 @@ module Aws::S3
|
|
|
646
674
|
# "MetadataKey" => "MetadataValue",
|
|
647
675
|
# },
|
|
648
676
|
# server_side_encryption: "AES256", # accepts AES256, aws:kms
|
|
649
|
-
# storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE
|
|
677
|
+
# storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, OUTPOSTS
|
|
650
678
|
# website_redirect_location: "WebsiteRedirectLocation",
|
|
651
679
|
# sse_customer_algorithm: "SSECustomerAlgorithm",
|
|
652
680
|
# sse_customer_key: "SSECustomerKey",
|
|
@@ -663,6 +691,8 @@ module Aws::S3
|
|
|
663
691
|
# @param [Hash] options ({})
|
|
664
692
|
# @option options [String] :acl
|
|
665
693
|
# The canned ACL to apply to the object.
|
|
694
|
+
#
|
|
695
|
+
# This action is not supported by Amazon S3 on Outposts.
|
|
666
696
|
# @option options [String] :cache_control
|
|
667
697
|
# Specifies caching behavior along the request/reply chain.
|
|
668
698
|
# @option options [String] :content_disposition
|
|
@@ -680,19 +710,36 @@ module Aws::S3
|
|
|
680
710
|
# @option options [String] :grant_full_control
|
|
681
711
|
# Gives the grantee READ, READ\_ACP, and WRITE\_ACP permissions on the
|
|
682
712
|
# object.
|
|
713
|
+
#
|
|
714
|
+
# This action is not supported by Amazon S3 on Outposts.
|
|
683
715
|
# @option options [String] :grant_read
|
|
684
716
|
# Allows grantee to read the object data and its metadata.
|
|
717
|
+
#
|
|
718
|
+
# This action is not supported by Amazon S3 on Outposts.
|
|
685
719
|
# @option options [String] :grant_read_acp
|
|
686
720
|
# Allows grantee to read the object ACL.
|
|
721
|
+
#
|
|
722
|
+
# This action is not supported by Amazon S3 on Outposts.
|
|
687
723
|
# @option options [String] :grant_write_acp
|
|
688
724
|
# Allows grantee to write the ACL for the applicable object.
|
|
725
|
+
#
|
|
726
|
+
# This action is not supported by Amazon S3 on Outposts.
|
|
689
727
|
# @option options [Hash<String,String>] :metadata
|
|
690
728
|
# A map of metadata to store with the object in S3.
|
|
691
729
|
# @option options [String] :server_side_encryption
|
|
692
730
|
# The server-side encryption algorithm used when storing this object in
|
|
693
731
|
# Amazon S3 (for example, AES256, aws:kms).
|
|
694
732
|
# @option options [String] :storage_class
|
|
695
|
-
#
|
|
733
|
+
# By default, Amazon S3 uses the STANDARD Storage Class to store newly
|
|
734
|
+
# created objects. The STANDARD storage class provides high durability
|
|
735
|
+
# and high availability. Depending on performance needs, you can specify
|
|
736
|
+
# a different Storage Class. Amazon S3 on Outposts only uses the
|
|
737
|
+
# OUTPOSTS Storage Class. For more information, see [Storage Classes][1]
|
|
738
|
+
# in the *Amazon S3 Service Developer Guide*.
|
|
739
|
+
#
|
|
740
|
+
#
|
|
741
|
+
#
|
|
742
|
+
# [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/storage-class-intro.html
|
|
696
743
|
# @option options [String] :website_redirect_location
|
|
697
744
|
# If the bucket is configured as a website, redirects requests for this
|
|
698
745
|
# object to another object in the same bucket or to an external URL.
|
|
@@ -786,7 +833,7 @@ module Aws::S3
|
|
|
786
833
|
# "MetadataKey" => "MetadataValue",
|
|
787
834
|
# },
|
|
788
835
|
# server_side_encryption: "AES256", # accepts AES256, aws:kms
|
|
789
|
-
# storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE
|
|
836
|
+
# storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, OUTPOSTS
|
|
790
837
|
# website_redirect_location: "WebsiteRedirectLocation",
|
|
791
838
|
# sse_customer_algorithm: "SSECustomerAlgorithm",
|
|
792
839
|
# sse_customer_key: "SSECustomerKey",
|
|
@@ -805,6 +852,8 @@ module Aws::S3
|
|
|
805
852
|
# The canned ACL to apply to the object. For more information, see
|
|
806
853
|
# [Canned ACL][1].
|
|
807
854
|
#
|
|
855
|
+
# This action is not supported by Amazon S3 on Outposts.
|
|
856
|
+
#
|
|
808
857
|
#
|
|
809
858
|
#
|
|
810
859
|
# [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#CannedACL
|
|
@@ -876,20 +925,36 @@ module Aws::S3
|
|
|
876
925
|
# @option options [String] :grant_full_control
|
|
877
926
|
# Gives the grantee READ, READ\_ACP, and WRITE\_ACP permissions on the
|
|
878
927
|
# object.
|
|
928
|
+
#
|
|
929
|
+
# This action is not supported by Amazon S3 on Outposts.
|
|
879
930
|
# @option options [String] :grant_read
|
|
880
931
|
# Allows grantee to read the object data and its metadata.
|
|
932
|
+
#
|
|
933
|
+
# This action is not supported by Amazon S3 on Outposts.
|
|
881
934
|
# @option options [String] :grant_read_acp
|
|
882
935
|
# Allows grantee to read the object ACL.
|
|
936
|
+
#
|
|
937
|
+
# This action is not supported by Amazon S3 on Outposts.
|
|
883
938
|
# @option options [String] :grant_write_acp
|
|
884
939
|
# Allows grantee to write the ACL for the applicable object.
|
|
940
|
+
#
|
|
941
|
+
# This action is not supported by Amazon S3 on Outposts.
|
|
885
942
|
# @option options [Hash<String,String>] :metadata
|
|
886
943
|
# A map of metadata to store with the object in S3.
|
|
887
944
|
# @option options [String] :server_side_encryption
|
|
888
945
|
# The server-side encryption algorithm used when storing this object in
|
|
889
946
|
# Amazon S3 (for example, AES256, aws:kms).
|
|
890
947
|
# @option options [String] :storage_class
|
|
891
|
-
#
|
|
892
|
-
#
|
|
948
|
+
# By default, Amazon S3 uses the STANDARD Storage Class to store newly
|
|
949
|
+
# created objects. The STANDARD storage class provides high durability
|
|
950
|
+
# and high availability. Depending on performance needs, you can specify
|
|
951
|
+
# a different Storage Class. Amazon S3 on Outposts only uses the
|
|
952
|
+
# OUTPOSTS Storage Class. For more information, see [Storage Classes][1]
|
|
953
|
+
# in the *Amazon S3 Service Developer Guide*.
|
|
954
|
+
#
|
|
955
|
+
#
|
|
956
|
+
#
|
|
957
|
+
# [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/storage-class-intro.html
|
|
893
958
|
# @option options [String] :website_redirect_location
|
|
894
959
|
# If the bucket is configured as a website, redirects requests for this
|
|
895
960
|
# object to another object in the same bucket or to an external URL.
|
|
@@ -1063,7 +1128,7 @@ module Aws::S3
|
|
|
1063
1128
|
# value: "MetadataValue",
|
|
1064
1129
|
# },
|
|
1065
1130
|
# ],
|
|
1066
|
-
# storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE
|
|
1131
|
+
# storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, OUTPOSTS
|
|
1067
1132
|
# },
|
|
1068
1133
|
# },
|
|
1069
1134
|
# },
|
|
@@ -403,12 +403,16 @@ module Aws::S3
|
|
|
403
403
|
# @option options [String] :range
|
|
404
404
|
# Downloads the specified range bytes of an object. For more information
|
|
405
405
|
# about the HTTP Range header, see
|
|
406
|
-
# [http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35]
|
|
406
|
+
# [http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35][1].
|
|
407
407
|
#
|
|
408
408
|
# <note markdown="1"> Amazon S3 doesn't support retrieving multiple ranges of data per
|
|
409
409
|
# `GET` request.
|
|
410
410
|
#
|
|
411
411
|
# </note>
|
|
412
|
+
#
|
|
413
|
+
#
|
|
414
|
+
#
|
|
415
|
+
# [1]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35
|
|
412
416
|
# @option options [String] :sse_customer_algorithm
|
|
413
417
|
# Specifies the algorithm to use to when encrypting the object (for
|
|
414
418
|
# example, AES256).
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../arn/access_point_arn'
|
|
4
|
+
require_relative '../arn/outpost_access_point_arn'
|
|
5
|
+
|
|
6
|
+
module Aws
|
|
7
|
+
module S3
|
|
8
|
+
module Plugins
|
|
9
|
+
# When an accesspoint ARN is provided for :bucket in S3 operations, this
|
|
10
|
+
# plugin resolves the request endpoint from the ARN when possible.
|
|
11
|
+
# @api private
|
|
12
|
+
class ARN < Seahorse::Client::Plugin
|
|
13
|
+
option(
|
|
14
|
+
:s3_use_arn_region,
|
|
15
|
+
default: true,
|
|
16
|
+
doc_type: 'Boolean',
|
|
17
|
+
docstring: <<-DOCS) do |cfg|
|
|
18
|
+
For S3 ARNs passed into the `:bucket` parameter, this option will
|
|
19
|
+
use the region in the ARN, allowing for cross-region requests to
|
|
20
|
+
be made. Set to `false` to use the client's region instead.
|
|
21
|
+
DOCS
|
|
22
|
+
resolve_s3_use_arn_region(cfg)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def add_handlers(handlers, _config)
|
|
26
|
+
handlers.add(Handler)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
class Handler < Seahorse::Client::Handler
|
|
30
|
+
def call(context)
|
|
31
|
+
bucket_member = _bucket_member(context.operation.input.shape)
|
|
32
|
+
if bucket_member && (bucket = context.params[bucket_member])
|
|
33
|
+
resolved_region, arn = ARN.resolve_arn!(
|
|
34
|
+
bucket,
|
|
35
|
+
context.config.region,
|
|
36
|
+
context.config.s3_use_arn_region
|
|
37
|
+
)
|
|
38
|
+
if arn
|
|
39
|
+
validate_config!(context, arn)
|
|
40
|
+
|
|
41
|
+
ARN.resolve_url!(
|
|
42
|
+
context.http_request.endpoint,
|
|
43
|
+
arn,
|
|
44
|
+
resolved_region,
|
|
45
|
+
extract_dualstack_config!(context)
|
|
46
|
+
)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
@handler.call(context)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
private
|
|
53
|
+
|
|
54
|
+
def _bucket_member(input)
|
|
55
|
+
input.members.each do |member, ref|
|
|
56
|
+
return member if ref.shape.name == 'BucketName'
|
|
57
|
+
end
|
|
58
|
+
nil
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# other plugins use dualstack so disable it when we're done
|
|
62
|
+
def extract_dualstack_config!(context)
|
|
63
|
+
dualstack = context[:use_dualstack_endpoint]
|
|
64
|
+
context[:use_dualstack_endpoint] = false if dualstack
|
|
65
|
+
dualstack
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def validate_config!(context, arn)
|
|
69
|
+
unless context.config.regional_endpoint
|
|
70
|
+
raise ArgumentError,
|
|
71
|
+
'Cannot provide both an Access Point ARN and setting '\
|
|
72
|
+
':endpoint.'
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
if context.config.force_path_style
|
|
76
|
+
raise ArgumentError,
|
|
77
|
+
'Cannot provide both an Access Point ARN and setting '\
|
|
78
|
+
':force_path_style to true.'
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
if context.config.use_accelerate_endpoint
|
|
82
|
+
raise ArgumentError,
|
|
83
|
+
'Cannot provide both an Access Point ARN and setting '\
|
|
84
|
+
':use_accelerate_endpoint to true.'
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
if !arn.support_dualstack? && context[:use_dualstack_endpoint]
|
|
88
|
+
raise ArgumentError,
|
|
89
|
+
'Cannot provide both an Outpost Access Point ARN and '\
|
|
90
|
+
'setting :use_dualstack_endpoint to true.'
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
class << self
|
|
96
|
+
# @api private
|
|
97
|
+
def resolve_arn!(member_value, region, use_arn_region)
|
|
98
|
+
if Aws::ARNParser.arn?(member_value)
|
|
99
|
+
arn = Aws::ARNParser.parse(member_value)
|
|
100
|
+
if arn.resource.start_with?('accesspoint')
|
|
101
|
+
s3_arn = Aws::S3::AccessPointARN.new(arn.to_h)
|
|
102
|
+
elsif arn.resource.start_with?('outpost')
|
|
103
|
+
s3_arn = Aws::S3::OutpostAccessPointARN.new(arn.to_h)
|
|
104
|
+
else
|
|
105
|
+
raise ArgumentError,
|
|
106
|
+
'Only Access Point and Outpost Access Point type ARNs '\
|
|
107
|
+
'are currently supported.'
|
|
108
|
+
end
|
|
109
|
+
s3_arn.validate_arn!
|
|
110
|
+
validate_region_config!(s3_arn, region, use_arn_region)
|
|
111
|
+
region = s3_arn.region if use_arn_region
|
|
112
|
+
[region, s3_arn]
|
|
113
|
+
else
|
|
114
|
+
[region]
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# @api private
|
|
119
|
+
def resolve_url!(url, arn, region, dualstack = false)
|
|
120
|
+
url.host = arn.host_url(region, dualstack)
|
|
121
|
+
url.path = url_path(url.path, arn)
|
|
122
|
+
url
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
private
|
|
126
|
+
|
|
127
|
+
def resolve_s3_use_arn_region(cfg)
|
|
128
|
+
value = ENV['AWS_S3_USE_ARN_REGION'] ||
|
|
129
|
+
Aws.shared_config.s3_use_arn_region(profile: cfg.profile) ||
|
|
130
|
+
'true'
|
|
131
|
+
value = Aws::Util.str_2_bool(value)
|
|
132
|
+
# Raise if provided value is not true or false
|
|
133
|
+
if value.nil?
|
|
134
|
+
raise ArgumentError,
|
|
135
|
+
'Must provide either `true` or `false` for '\
|
|
136
|
+
's3_use_arn_region profile option or for '\
|
|
137
|
+
"ENV['AWS_S3_USE_ARN_REGION']"
|
|
138
|
+
end
|
|
139
|
+
value
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# Remove ARN from the path since it was substituted already
|
|
143
|
+
# This only works because accesspoints care about the URL
|
|
144
|
+
def url_path(path, arn)
|
|
145
|
+
path = path.sub("/#{Seahorse::Util.uri_escape(arn.to_s)}", '')
|
|
146
|
+
.sub("/#{arn}", '')
|
|
147
|
+
"/#{path}" unless path =~ /^\//
|
|
148
|
+
path
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
def validate_region_config!(arn, region, use_arn_region)
|
|
152
|
+
fips = arn.support_fips?
|
|
153
|
+
|
|
154
|
+
# s3-external-1 is specific just to s3 and not part of partitions
|
|
155
|
+
# aws-global is a partition region
|
|
156
|
+
unless arn.partition == 'aws' &&
|
|
157
|
+
(region == 's3-external-1' || region == 'aws-global')
|
|
158
|
+
if !fips && arn.region.include?('fips')
|
|
159
|
+
raise ArgumentError,
|
|
160
|
+
'FIPS region ARNs are not supported for this type of ARN.'
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
if !fips && !use_arn_region && region.include?('fips')
|
|
164
|
+
raise ArgumentError,
|
|
165
|
+
'FIPS client regions are not supported for this type of '\
|
|
166
|
+
'ARN without s3_use_arn_region.'
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
# if it's a fips region, attempt to normalize it
|
|
170
|
+
if fips || use_arn_region
|
|
171
|
+
region = region.gsub('fips-', '').gsub('-fips', '')
|
|
172
|
+
end
|
|
173
|
+
if use_arn_region &&
|
|
174
|
+
!Aws::Partitions.partition(arn.partition).region?(region)
|
|
175
|
+
raise Aws::Errors::InvalidARNPartitionError
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
if !use_arn_region && region != arn.region
|
|
179
|
+
raise Aws::Errors::InvalidARNRegionError
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
end
|
|
@@ -73,8 +73,6 @@ request URI and never moved to the host as a sub-domain.
|
|
|
73
73
|
end
|
|
74
74
|
end
|
|
75
75
|
|
|
76
|
-
# Checks for a valid RFC-3986 host name
|
|
77
|
-
# @see https://tools.ietf.org/html/rfc3986#section-3.2.2
|
|
78
76
|
# @param [String] bucket_name
|
|
79
77
|
# @return [Boolean]
|
|
80
78
|
def valid_subdomain?(bucket_name)
|
|
@@ -13,7 +13,7 @@ module Aws
|
|
|
13
13
|
def call(context)
|
|
14
14
|
bucket_member = _bucket_member(context.operation.input.shape)
|
|
15
15
|
if bucket_member && (bucket = context.params[bucket_member])
|
|
16
|
-
|
|
16
|
+
_resolved_region, arn = ARN.resolve_arn!(
|
|
17
17
|
bucket,
|
|
18
18
|
context.config.region,
|
|
19
19
|
context.config.s3_use_arn_region
|
|
@@ -28,8 +28,13 @@ region. Defaults to `legacy` mode using global endpoint.
|
|
|
28
28
|
def call(context)
|
|
29
29
|
# keep legacy global endpoint pattern by default
|
|
30
30
|
if context.config.s3_us_east_1_regional_endpoint == 'legacy'
|
|
31
|
-
context.http_request.endpoint.host
|
|
32
|
-
|
|
31
|
+
host = context.http_request.endpoint.host
|
|
32
|
+
# if it's an ARN, don't touch the endpoint at all
|
|
33
|
+
# TODO this should use context.metadata[:s3_arn] later
|
|
34
|
+
unless host.include?('.s3-outposts.') || host.include?('.s3-accesspoint.')
|
|
35
|
+
legacy_host = IADRegionalEndpoint.legacy_host(host)
|
|
36
|
+
context.http_request.endpoint.host = legacy_host
|
|
37
|
+
end
|
|
33
38
|
end
|
|
34
39
|
@handler.call(context)
|
|
35
40
|
end
|
|
@@ -12,12 +12,14 @@ module Aws
|
|
|
12
12
|
|
|
13
13
|
option(:sigv4_signer) do |cfg|
|
|
14
14
|
S3Signer.build_v4_signer(
|
|
15
|
+
service: 's3',
|
|
15
16
|
region: cfg.sigv4_region,
|
|
16
17
|
credentials: cfg.credentials
|
|
17
18
|
)
|
|
18
19
|
end
|
|
19
20
|
|
|
20
21
|
option(:sigv4_region) do |cfg|
|
|
22
|
+
# S3 removes core's signature_v4 plugin that checks for this
|
|
21
23
|
raise Aws::Errors::MissingRegionError if cfg.region.nil?
|
|
22
24
|
|
|
23
25
|
Aws::Partitions::EndpointProvider.signing_region(cfg.region, 's3')
|
|
@@ -67,11 +69,26 @@ module Aws
|
|
|
67
69
|
if context[:cached_sigv4_region] &&
|
|
68
70
|
context[:cached_sigv4_region] != context.config.sigv4_signer.region
|
|
69
71
|
S3Signer.build_v4_signer(
|
|
72
|
+
service: 's3',
|
|
70
73
|
region: context[:cached_sigv4_region],
|
|
71
74
|
credentials: context.config.credentials
|
|
72
75
|
)
|
|
73
76
|
else
|
|
74
|
-
|
|
77
|
+
resolved_region, arn = ARN.resolve_arn!(
|
|
78
|
+
context.params[:bucket],
|
|
79
|
+
context.config.sigv4_signer.region,
|
|
80
|
+
context.config.s3_use_arn_region
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
if arn
|
|
84
|
+
S3Signer.build_v4_signer(
|
|
85
|
+
service: arn.respond_to?(:outpost_id) ? 's3-outposts' : 's3',
|
|
86
|
+
region: resolved_region,
|
|
87
|
+
credentials: context.config.credentials
|
|
88
|
+
)
|
|
89
|
+
else
|
|
90
|
+
context.config.sigv4_signer
|
|
91
|
+
end
|
|
75
92
|
end
|
|
76
93
|
end
|
|
77
94
|
end
|
|
@@ -90,7 +107,9 @@ module Aws
|
|
|
90
107
|
def check_for_cached_region(context, bucket)
|
|
91
108
|
cached_region = S3::BUCKET_REGIONS[bucket]
|
|
92
109
|
if cached_region && cached_region != context.config.region
|
|
93
|
-
context.http_request.endpoint.host = S3Signer.new_hostname(
|
|
110
|
+
context.http_request.endpoint.host = S3Signer.new_hostname(
|
|
111
|
+
context, cached_region
|
|
112
|
+
)
|
|
94
113
|
context[:cached_sigv4_region] = cached_region
|
|
95
114
|
end
|
|
96
115
|
end
|
|
@@ -150,11 +169,14 @@ module Aws
|
|
|
150
169
|
|
|
151
170
|
def resign_with_new_region(context, actual_region)
|
|
152
171
|
context.http_response.body.truncate(0)
|
|
153
|
-
context.http_request.endpoint.host = S3Signer.new_hostname(
|
|
172
|
+
context.http_request.endpoint.host = S3Signer.new_hostname(
|
|
173
|
+
context, actual_region
|
|
174
|
+
)
|
|
154
175
|
context.metadata[:redirect_region] = actual_region
|
|
155
176
|
Aws::Plugins::SignatureV4.apply_signature(
|
|
156
177
|
context: context,
|
|
157
178
|
signer: S3Signer.build_v4_signer(
|
|
179
|
+
service: 's3',
|
|
158
180
|
region: actual_region,
|
|
159
181
|
credentials: context.config.credentials
|
|
160
182
|
)
|
|
@@ -189,7 +211,7 @@ module Aws
|
|
|
189
211
|
# @api private
|
|
190
212
|
def build_v4_signer(options = {})
|
|
191
213
|
Aws::Sigv4::Signer.new(
|
|
192
|
-
service:
|
|
214
|
+
service: options[:service],
|
|
193
215
|
region: options[:region],
|
|
194
216
|
credentials_provider: options[:credentials],
|
|
195
217
|
uri_escape_path: false,
|
|
@@ -200,7 +222,7 @@ module Aws
|
|
|
200
222
|
def new_hostname(context, region)
|
|
201
223
|
# Check to see if the bucket is actually an ARN and resolve it
|
|
202
224
|
# Otherwise it will retry with the ARN as the bucket name.
|
|
203
|
-
|
|
225
|
+
resolved_region, arn = ARN.resolve_arn!(
|
|
204
226
|
context.params[:bucket],
|
|
205
227
|
region,
|
|
206
228
|
context.config.s3_use_arn_region
|
|
@@ -210,9 +232,9 @@ module Aws
|
|
|
210
232
|
)
|
|
211
233
|
|
|
212
234
|
if arn
|
|
213
|
-
|
|
235
|
+
ARN.resolve_url!(uri, arn).host
|
|
214
236
|
else
|
|
215
|
-
|
|
237
|
+
"#{context.params[:bucket]}.#{uri.host}"
|
|
216
238
|
end
|
|
217
239
|
end
|
|
218
240
|
end
|