aws-sdk-s3 1.132.0 → 1.151.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 (75) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +127 -1
  3. data/VERSION +1 -1
  4. data/lib/aws-sdk-s3/access_grants_credentials.rb +57 -0
  5. data/lib/aws-sdk-s3/access_grants_credentials_provider.rb +241 -0
  6. data/lib/aws-sdk-s3/bucket.rb +424 -81
  7. data/lib/aws-sdk-s3/bucket_acl.rb +9 -9
  8. data/lib/aws-sdk-s3/bucket_cors.rb +12 -12
  9. data/lib/aws-sdk-s3/bucket_lifecycle.rb +12 -12
  10. data/lib/aws-sdk-s3/bucket_lifecycle_configuration.rb +12 -12
  11. data/lib/aws-sdk-s3/bucket_logging.rb +16 -9
  12. data/lib/aws-sdk-s3/bucket_notification.rb +3 -3
  13. data/lib/aws-sdk-s3/bucket_policy.rb +58 -14
  14. data/lib/aws-sdk-s3/bucket_region_cache.rb +9 -5
  15. data/lib/aws-sdk-s3/bucket_request_payment.rb +9 -9
  16. data/lib/aws-sdk-s3/bucket_tagging.rb +12 -12
  17. data/lib/aws-sdk-s3/bucket_versioning.rb +27 -27
  18. data/lib/aws-sdk-s3/bucket_website.rb +12 -12
  19. data/lib/aws-sdk-s3/client.rb +5783 -2608
  20. data/lib/aws-sdk-s3/client_api.rb +114 -18
  21. data/lib/aws-sdk-s3/customizations/errors.rb +15 -2
  22. data/lib/aws-sdk-s3/customizations/object.rb +45 -2
  23. data/lib/aws-sdk-s3/customizations.rb +8 -0
  24. data/lib/aws-sdk-s3/endpoint_parameters.rb +32 -0
  25. data/lib/aws-sdk-s3/endpoint_provider.rb +88 -6
  26. data/lib/aws-sdk-s3/endpoints.rb +440 -0
  27. data/lib/aws-sdk-s3/express_credentials.rb +55 -0
  28. data/lib/aws-sdk-s3/express_credentials_provider.rb +59 -0
  29. data/lib/aws-sdk-s3/file_downloader.rb +119 -24
  30. data/lib/aws-sdk-s3/multipart_file_uploader.rb +4 -4
  31. data/lib/aws-sdk-s3/multipart_stream_uploader.rb +5 -4
  32. data/lib/aws-sdk-s3/multipart_upload.rb +69 -16
  33. data/lib/aws-sdk-s3/multipart_upload_part.rb +160 -35
  34. data/lib/aws-sdk-s3/object.rb +1504 -235
  35. data/lib/aws-sdk-s3/object_acl.rb +29 -15
  36. data/lib/aws-sdk-s3/object_multipart_copier.rb +10 -8
  37. data/lib/aws-sdk-s3/object_summary.rb +1367 -254
  38. data/lib/aws-sdk-s3/object_version.rb +297 -42
  39. data/lib/aws-sdk-s3/plugins/access_grants.rb +108 -0
  40. data/lib/aws-sdk-s3/plugins/endpoints.rb +14 -2
  41. data/lib/aws-sdk-s3/plugins/express_session_auth.rb +91 -0
  42. data/lib/aws-sdk-s3/plugins/location_constraint.rb +3 -1
  43. data/lib/aws-sdk-s3/plugins/md5s.rb +2 -1
  44. data/lib/aws-sdk-s3/plugins/s3_signer.rb +7 -2
  45. data/lib/aws-sdk-s3/presigner.rb +4 -2
  46. data/lib/aws-sdk-s3/resource.rb +83 -11
  47. data/lib/aws-sdk-s3/types.rb +4529 -1361
  48. data/lib/aws-sdk-s3.rb +1 -1
  49. data/sig/bucket.rbs +212 -0
  50. data/sig/bucket_acl.rbs +78 -0
  51. data/sig/bucket_cors.rbs +69 -0
  52. data/sig/bucket_lifecycle.rbs +88 -0
  53. data/sig/bucket_lifecycle_configuration.rbs +111 -0
  54. data/sig/bucket_logging.rbs +76 -0
  55. data/sig/bucket_notification.rbs +114 -0
  56. data/sig/bucket_policy.rbs +59 -0
  57. data/sig/bucket_request_payment.rbs +54 -0
  58. data/sig/bucket_tagging.rbs +65 -0
  59. data/sig/bucket_versioning.rbs +77 -0
  60. data/sig/bucket_website.rbs +93 -0
  61. data/sig/client.rbs +2362 -0
  62. data/sig/customizations/bucket.rbs +19 -0
  63. data/sig/customizations/object.rbs +38 -0
  64. data/sig/customizations/object_summary.rbs +35 -0
  65. data/sig/errors.rbs +34 -0
  66. data/sig/multipart_upload.rbs +110 -0
  67. data/sig/multipart_upload_part.rbs +105 -0
  68. data/sig/object.rbs +436 -0
  69. data/sig/object_acl.rbs +86 -0
  70. data/sig/object_summary.rbs +334 -0
  71. data/sig/object_version.rbs +131 -0
  72. data/sig/resource.rbs +126 -0
  73. data/sig/types.rbs +2562 -0
  74. data/sig/waiters.rbs +83 -0
  75. metadata +43 -11
@@ -0,0 +1,91 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ module S3
5
+ module Plugins
6
+ # @api private
7
+ class ExpressSessionAuth < Seahorse::Client::Plugin
8
+ # This should be s3_disable_express_auth instead
9
+ # But this is not a built in. We're overwriting the generated value
10
+ option(:disable_s3_express_session_auth,
11
+ default: false,
12
+ doc_type: 'Boolean',
13
+ docstring: <<-DOCS) do |cfg|
14
+ When `true`, S3 Express session authentication is disabled.
15
+ DOCS
16
+ resolve_disable_s3_express_session_auth(cfg)
17
+ end
18
+
19
+ option(:express_credentials_provider,
20
+ doc_type: 'Aws::S3::ExpressCredentialsProvider',
21
+ rbs_type: 'untyped',
22
+ docstring: <<-DOCS) do |_cfg|
23
+ Credential Provider for S3 Express endpoints. Manages credentials
24
+ for different buckets.
25
+ DOCS
26
+ Aws::S3::ExpressCredentialsProvider.new
27
+ end
28
+
29
+ # @api private
30
+ class Handler < Seahorse::Client::Handler
31
+ def call(context)
32
+ if (props = context[:endpoint_properties])
33
+ # S3 Express endpoint - turn off md5 and enable crc32 default
34
+ if props['backend'] == 'S3Express'
35
+ if context.operation_name == :put_object || checksum_required?(context)
36
+ context[:default_request_checksum_algorithm] = 'CRC32'
37
+ end
38
+ context[:s3_express_endpoint] = true
39
+ end
40
+
41
+ # if s3 express auth, use new credentials and sign additional header
42
+ if context[:auth_scheme]['name'] == 'sigv4-s3express' &&
43
+ !context.config.disable_s3_express_session_auth
44
+ bucket = context.params[:bucket]
45
+ credentials_provider = context.config.express_credentials_provider
46
+ credentials = credentials_provider.express_credentials_for(bucket)
47
+ context[:sigv4_credentials] = credentials # Sign will use this
48
+ end
49
+ end
50
+ @handler.call(context)
51
+ end
52
+
53
+ private
54
+
55
+ def checksum_required?(context)
56
+ context.operation.http_checksum_required ||
57
+ (context.operation.http_checksum &&
58
+ context.operation.http_checksum['requestChecksumRequired'])
59
+ end
60
+ end
61
+
62
+ handler(Handler)
63
+
64
+ # Optimization - sets this client as the client to create sessions.
65
+ def after_initialize(client)
66
+ provider = client.config.express_credentials_provider
67
+ provider.client = client unless provider.client
68
+ end
69
+
70
+ class << self
71
+ private
72
+
73
+ def resolve_disable_s3_express_session_auth(cfg)
74
+ value = ENV['AWS_S3_DISABLE_EXPRESS_SESSION_AUTH'] ||
75
+ Aws.shared_config.s3_disable_express_session_auth(profile: cfg.profile) ||
76
+ 'false'
77
+ value = Aws::Util.str_2_bool(value)
78
+ # Raise if provided value is not true or false
79
+ if value.nil?
80
+ raise ArgumentError,
81
+ 'Must provide either `true` or `false` for the '\
82
+ '`s3_disable_express_session_auth` profile option or for '\
83
+ "ENV['AWS_S3_DISABLE_EXPRESS_SESSION_AUTH']."
84
+ end
85
+ value
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
@@ -22,7 +22,9 @@ module Aws
22
22
 
23
23
  def populate_location_constraint(params, region)
24
24
  params[:create_bucket_configuration] ||= {}
25
- params[:create_bucket_configuration][:location_constraint] ||= region
25
+ unless params[:create_bucket_configuration][:location]
26
+ params[:create_bucket_configuration][:location_constraint] ||= region
27
+ end
26
28
  end
27
29
 
28
30
  end
@@ -22,7 +22,8 @@ module Aws
22
22
  CHUNK_SIZE = 1 * 1024 * 1024 # one MB
23
23
 
24
24
  def call(context)
25
- if !context[:checksum_algorithms] # skip in favor of flexible checksum
25
+ if !context[:checksum_algorithms] && # skip in favor of flexible checksum
26
+ !context[:s3_express_endpoint] # s3 express endpoints do not support md5
26
27
  body = context.http_request.body
27
28
  if body.respond_to?(:size) && body.size > 0
28
29
  context.http_request.headers['Content-Md5'] ||= md5(body)
@@ -4,6 +4,11 @@ require 'aws-sigv4'
4
4
 
5
5
  module Aws
6
6
  module S3
7
+ # @api private
8
+ def self.bucket_region_cache
9
+ @bucket_region_cache ||= BucketRegionCache.new
10
+ end
11
+
7
12
  module Plugins
8
13
  # This plugin used to have a V4 signer but it was removed in favor of
9
14
  # generic Sign plugin that uses endpoint auth scheme.
@@ -51,7 +56,7 @@ module Aws
51
56
  private
52
57
 
53
58
  def check_for_cached_region(context, bucket)
54
- cached_region = S3::BUCKET_REGIONS[bucket]
59
+ cached_region = Aws::S3.bucket_region_cache[bucket]
55
60
  if cached_region &&
56
61
  cached_region != context.config.region &&
57
62
  !S3Signer.custom_endpoint?(context)
@@ -97,7 +102,7 @@ module Aws
97
102
  end
98
103
 
99
104
  def update_bucket_cache(context, actual_region)
100
- S3::BUCKET_REGIONS[context.params[:bucket]] = actual_region
105
+ Aws::S3.bucket_region_cache[context.params[:bucket]] = actual_region
101
106
  end
102
107
 
103
108
  def fips_region?(resp)
@@ -199,6 +199,8 @@ module Aws
199
199
  req.handlers.remove(Aws::S3::Plugins::S3Signer::LegacyHandler)
200
200
  req.handlers.remove(Aws::Plugins::Sign::Handler)
201
201
  req.handlers.remove(Seahorse::Client::Plugins::ContentLength::Handler)
202
+ req.handlers.remove(Aws::Rest::ContentTypeHandler)
203
+ req.handlers.remove(Aws::Plugins::InvocationId::Handler)
202
204
 
203
205
  req.handle(step: :send) do |context|
204
206
  # if an endpoint was not provided, force secure or insecure
@@ -232,8 +234,8 @@ module Aws
232
234
  end
233
235
  signer = Aws::Sigv4::Signer.new(
234
236
  service: auth_scheme['signingName'] || 's3',
235
- region: region || context.config.region,
236
- credentials_provider: context.config.credentials,
237
+ region: context[:sigv4_region] || region || context.config.region,
238
+ credentials_provider: context[:sigv4_credentials] || context.config.credentials,
237
239
  signing_algorithm: scheme_name.to_sym,
238
240
  uri_escape_path: !!!auth_scheme['disableDoubleEncoding'],
239
241
  unsigned_headers: unsigned_headers,
@@ -41,7 +41,15 @@ module Aws::S3
41
41
  # acl: "private", # accepts private, public-read, public-read-write, authenticated-read
42
42
  # bucket: "BucketName", # required
43
43
  # create_bucket_configuration: {
44
- # location_constraint: "af-south-1", # accepts af-south-1, ap-east-1, ap-northeast-1, ap-northeast-2, ap-northeast-3, ap-south-1, ap-southeast-1, ap-southeast-2, ap-southeast-3, ca-central-1, cn-north-1, cn-northwest-1, EU, eu-central-1, eu-north-1, eu-south-1, eu-west-1, eu-west-2, eu-west-3, me-south-1, sa-east-1, us-east-2, us-gov-east-1, us-gov-west-1, us-west-1, us-west-2, ap-south-2, eu-south-2
44
+ # location_constraint: "af-south-1", # accepts af-south-1, ap-east-1, ap-northeast-1, ap-northeast-2, ap-northeast-3, ap-south-1, ap-south-2, ap-southeast-1, ap-southeast-2, ap-southeast-3, ca-central-1, cn-north-1, cn-northwest-1, EU, eu-central-1, eu-north-1, eu-south-1, eu-south-2, eu-west-1, eu-west-2, eu-west-3, me-south-1, sa-east-1, us-east-2, us-gov-east-1, us-gov-west-1, us-west-1, us-west-2
45
+ # location: {
46
+ # type: "AvailabilityZone", # accepts AvailabilityZone
47
+ # name: "LocationNameAsString",
48
+ # },
49
+ # bucket: {
50
+ # data_redundancy: "SingleAvailabilityZone", # accepts SingleAvailabilityZone
51
+ # type: "Directory", # accepts Directory
52
+ # },
45
53
  # },
46
54
  # grant_full_control: "GrantFullControl",
47
55
  # grant_read: "GrantRead",
@@ -54,44 +62,108 @@ module Aws::S3
54
62
  # @param [Hash] options ({})
55
63
  # @option options [String] :acl
56
64
  # The canned ACL to apply to the bucket.
65
+ #
66
+ # <note markdown="1"> This functionality is not supported for directory buckets.
67
+ #
68
+ # </note>
57
69
  # @option options [required, String] :bucket
58
70
  # The name of the bucket to create.
71
+ #
72
+ # **General purpose buckets** - For information about bucket naming
73
+ # restrictions, see [Bucket naming rules][1] in the *Amazon S3 User
74
+ # Guide*.
75
+ #
76
+ # <b>Directory buckets </b> - When you use this operation with a
77
+ # directory bucket, you must use path-style requests in the format
78
+ # `https://s3express-control.region_code.amazonaws.com/bucket-name `.
79
+ # Virtual-hosted-style requests aren't supported. Directory bucket
80
+ # names must be unique in the chosen Availability Zone. Bucket names
81
+ # must also follow the format ` bucket_base_name--az_id--x-s3` (for
82
+ # example, ` DOC-EXAMPLE-BUCKET--usw2-az1--x-s3`). For information about
83
+ # bucket naming restrictions, see [Directory bucket naming rules][2] in
84
+ # the *Amazon S3 User Guide*
85
+ #
86
+ #
87
+ #
88
+ # [1]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html
89
+ # [2]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/directory-bucket-naming-rules.html
59
90
  # @option options [Types::CreateBucketConfiguration] :create_bucket_configuration
60
91
  # The configuration information for the bucket.
61
92
  # @option options [String] :grant_full_control
62
93
  # Allows grantee the read, write, read ACP, and write ACP permissions on
63
94
  # the bucket.
95
+ #
96
+ # <note markdown="1"> This functionality is not supported for directory buckets.
97
+ #
98
+ # </note>
64
99
  # @option options [String] :grant_read
65
100
  # Allows grantee to list the objects in the bucket.
101
+ #
102
+ # <note markdown="1"> This functionality is not supported for directory buckets.
103
+ #
104
+ # </note>
66
105
  # @option options [String] :grant_read_acp
67
106
  # Allows grantee to read the bucket ACL.
107
+ #
108
+ # <note markdown="1"> This functionality is not supported for directory buckets.
109
+ #
110
+ # </note>
68
111
  # @option options [String] :grant_write
69
112
  # Allows grantee to create new objects in the bucket.
70
113
  #
71
114
  # For the bucket and object owners of existing objects, also allows
72
115
  # deletions and overwrites of those objects.
116
+ #
117
+ # <note markdown="1"> This functionality is not supported for directory buckets.
118
+ #
119
+ # </note>
73
120
  # @option options [String] :grant_write_acp
74
121
  # Allows grantee to write the ACL for the applicable bucket.
122
+ #
123
+ # <note markdown="1"> This functionality is not supported for directory buckets.
124
+ #
125
+ # </note>
75
126
  # @option options [Boolean] :object_lock_enabled_for_bucket
76
127
  # Specifies whether you want S3 Object Lock to be enabled for the new
77
128
  # bucket.
129
+ #
130
+ # <note markdown="1"> This functionality is not supported for directory buckets.
131
+ #
132
+ # </note>
78
133
  # @option options [String] :object_ownership
79
134
  # The container element for object ownership for a bucket's ownership
80
135
  # controls.
81
136
  #
82
- # BucketOwnerPreferred - Objects uploaded to the bucket change ownership
83
- # to the bucket owner if the objects are uploaded with the
137
+ # `BucketOwnerPreferred` - Objects uploaded to the bucket change
138
+ # ownership to the bucket owner if the objects are uploaded with the
84
139
  # `bucket-owner-full-control` canned ACL.
85
140
  #
86
- # ObjectWriter - The uploading account will own the object if the object
87
- # is uploaded with the `bucket-owner-full-control` canned ACL.
141
+ # `ObjectWriter` - The uploading account will own the object if the
142
+ # object is uploaded with the `bucket-owner-full-control` canned ACL.
143
+ #
144
+ # `BucketOwnerEnforced` - Access control lists (ACLs) are disabled and
145
+ # no longer affect permissions. The bucket owner automatically owns and
146
+ # has full control over every object in the bucket. The bucket only
147
+ # accepts PUT requests that don't specify an ACL or specify bucket
148
+ # owner full control ACLs (such as the predefined
149
+ # `bucket-owner-full-control` canned ACL or a custom ACL in XML format
150
+ # that grants the same permissions).
151
+ #
152
+ # By default, `ObjectOwnership` is set to `BucketOwnerEnforced` and ACLs
153
+ # are disabled. We recommend keeping ACLs disabled, except in uncommon
154
+ # use cases where you must control access for each object individually.
155
+ # For more information about S3 Object Ownership, see [Controlling
156
+ # ownership of objects and disabling ACLs for your bucket][1] in the
157
+ # *Amazon S3 User Guide*.
158
+ #
159
+ # <note markdown="1"> This functionality is not supported for directory buckets. Directory
160
+ # buckets use the bucket owner enforced setting for S3 Object Ownership.
161
+ #
162
+ # </note>
163
+ #
164
+ #
88
165
  #
89
- # BucketOwnerEnforced - Access control lists (ACLs) are disabled and no
90
- # longer affect permissions. The bucket owner automatically owns and has
91
- # full control over every object in the bucket. The bucket only accepts
92
- # PUT requests that don't specify an ACL or bucket owner full control
93
- # ACLs, such as the `bucket-owner-full-control` canned ACL or an
94
- # equivalent form of this ACL expressed in the XML format.
166
+ # [1]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/about-object-ownership.html
95
167
  # @return [Bucket]
96
168
  def create_bucket(options = {})
97
169
  Aws::Plugins::UserAgent.feature('resource') do