aws-sdk-s3 1.81.1 → 1.82.0

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-sdk-s3
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.81.1
4
+ version: 1.82.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amazon Web Services
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-25 00:00:00.000000000 Z
11
+ date: 2020-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-kms
@@ -47,7 +47,7 @@ dependencies:
47
47
  version: '3'
48
48
  - - ">="
49
49
  - !ruby/object:Gem::Version
50
- version: 3.104.3
50
+ version: 3.109.0
51
51
  type: :runtime
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
@@ -57,7 +57,7 @@ dependencies:
57
57
  version: '3'
58
58
  - - ">="
59
59
  - !ruby/object:Gem::Version
60
- version: 3.104.3
60
+ version: 3.109.0
61
61
  description: Official AWS Ruby gem for Amazon Simple Storage Service (Amazon S3).
62
62
  This gem is part of the AWS SDK for Ruby.
63
63
  email:
@@ -67,6 +67,8 @@ extensions: []
67
67
  extra_rdoc_files: []
68
68
  files:
69
69
  - lib/aws-sdk-s3.rb
70
+ - lib/aws-sdk-s3/arn/access_point_arn.rb
71
+ - lib/aws-sdk-s3/arn/outpost_access_point_arn.rb
70
72
  - lib/aws-sdk-s3/bucket.rb
71
73
  - lib/aws-sdk-s3/bucket_acl.rb
72
74
  - lib/aws-sdk-s3/bucket_cors.rb
@@ -134,7 +136,7 @@ files:
134
136
  - lib/aws-sdk-s3/object_summary.rb
135
137
  - lib/aws-sdk-s3/object_version.rb
136
138
  - lib/aws-sdk-s3/plugins/accelerate.rb
137
- - lib/aws-sdk-s3/plugins/bucket_arn.rb
139
+ - lib/aws-sdk-s3/plugins/arn.rb
138
140
  - lib/aws-sdk-s3/plugins/bucket_dns.rb
139
141
  - lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
140
142
  - lib/aws-sdk-s3/plugins/dualstack.rb
@@ -1,212 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Aws
4
- module S3
5
- module Plugins
6
- # When an accesspoint ARN is provided for :bucket in S3 operations, this
7
- # plugin resolves the request endpoint from the ARN when possible.
8
- class BucketARN < Seahorse::Client::Plugin
9
- option(
10
- :s3_use_arn_region,
11
- default: true,
12
- doc_type: 'Boolean',
13
- docstring: <<-DOCS) do |cfg|
14
- By default, the SDK will use the S3 ARN region, and cross-region
15
- requests could be made. Set to `false` to not use the region from
16
- the S3 ARN.
17
- DOCS
18
- resolve_s3_use_arn_region(cfg)
19
- end
20
-
21
- def add_handlers(handlers, _config)
22
- handlers.add(Handler)
23
- end
24
-
25
- # @api private
26
- class Handler < Seahorse::Client::Handler
27
- def call(context)
28
- bucket_member = _bucket_member(context.operation.input.shape)
29
- if bucket_member && (bucket = context.params[bucket_member])
30
- _resolved_bucket, _resolved_region, arn = BucketARN.resolve_arn!(
31
- bucket,
32
- context.config.region,
33
- context.config.s3_use_arn_region
34
- )
35
- if arn
36
- if arn.resource.start_with?('accesspoint')
37
- validate_config!(context.config)
38
- end
39
-
40
- dualstack = extract_dualstack_config!(context)
41
-
42
- BucketARN.resolve_url!(
43
- context.http_request.endpoint,
44
- arn,
45
- dualstack
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!(config)
69
- unless config.regional_endpoint
70
- raise ArgumentError,
71
- 'Cannot provide both an accesspoint ARN and :endpoint.'
72
- end
73
-
74
- if config.use_accelerate_endpoint
75
- raise ArgumentError,
76
- 'Cannot provide both an accesspoint ARN and setting '\
77
- ':use_accelerate_endpoint to true.'
78
- end
79
-
80
- if config.force_path_style
81
- raise ArgumentError,
82
- 'Cannot provide both an accesspoint ARN and setting '\
83
- ':force_path_style to true.'
84
- end
85
- end
86
- end
87
-
88
- class << self
89
-
90
- # @api private
91
- def resolve_arn!(bucket_name, region, s3_use_arn_region)
92
- if Aws::ARNParser.arn?(bucket_name)
93
- arn = Aws::ARNParser.parse(bucket_name)
94
- validate_s3_arn!(arn)
95
- validate_region!(arn, region, s3_use_arn_region)
96
- if arn.resource.start_with?('accesspoint')
97
- region = arn.region if s3_use_arn_region
98
- [bucket_name, region, arn]
99
- else
100
- raise ArgumentError,
101
- 'Only accesspoint type ARNs are currently supported.'
102
- end
103
- else
104
- [bucket_name, region]
105
- end
106
- end
107
-
108
- # @api private
109
- def resolve_url!(url, arn, dualstack = false)
110
- if arn.resource.start_with?('accesspoint')
111
- url.host = accesspoint_arn_host(arn, dualstack)
112
- else
113
- raise ArgumentError,
114
- 'Only accesspoint type ARNs are currently supported.'
115
- end
116
- url.path = url_path(url.path, arn)
117
- url
118
- end
119
-
120
- private
121
-
122
- def accesspoint_arn_host(arn, dualstack)
123
- _resource_type, resource_name = parse_resource(arn.resource)
124
- sfx = Aws::Partitions::EndpointProvider.dns_suffix_for(arn.region)
125
- "#{resource_name}-#{arn.account_id}"\
126
- '.s3-accesspoint'\
127
- "#{'.dualstack' if dualstack}"\
128
- ".#{arn.region}.#{sfx}"
129
- end
130
-
131
- def parse_resource(str)
132
- slash = str.index('/') || str.length
133
- colon = str.index(':') || str.length
134
- delimiter = slash < colon ? slash : colon
135
- if delimiter < str.length
136
- [str[0..(delimiter - 1)], str[(delimiter + 1)..-1]]
137
- else
138
- [nil, str]
139
- end
140
- end
141
-
142
- def resolve_s3_use_arn_region(cfg)
143
- value = ENV['AWS_S3_USE_ARN_REGION'] ||
144
- Aws.shared_config.s3_use_arn_region(profile: cfg.profile) ||
145
- 'true'
146
-
147
- # Raise if provided value is not true or false
148
- if value != 'true' && value != 'false'
149
- raise ArgumentError,
150
- 'Must provide either `true` or `false` for '\
151
- 's3_use_arn_region profile option or for '\
152
- 'ENV[\'AWS_S3_USE_ARN_REGION\']'
153
- end
154
-
155
- value == 'true'
156
- end
157
-
158
- def url_path(path, arn)
159
- path = path.sub("/#{Seahorse::Util.uri_escape(arn.to_s)}", '')
160
- .sub("/#{arn}", '')
161
- "/#{path}" unless path.match(/^\//)
162
- path
163
- end
164
-
165
- def validate_s3_arn!(arn)
166
- _resource_type, resource_name = parse_resource(arn.resource)
167
-
168
- unless arn.service == 's3'
169
- raise ArgumentError, 'Must provide an S3 ARN.'
170
- end
171
-
172
- if arn.region.empty? || arn.account_id.empty?
173
- raise ArgumentError,
174
- 'S3 Access Point ARNs must contain both a valid region '\
175
- ' and a valid account id.'
176
- end
177
-
178
- if resource_name.include?(':') || resource_name.include?('/')
179
- raise ArgumentError,
180
- 'ARN resource id must be a single value.'
181
- end
182
-
183
- unless Plugins::BucketDns.valid_subdomain?(
184
- "#{resource_name}-#{arn.account_id}"
185
- )
186
- raise ArgumentError,
187
- "#{resource_name}-#{arn.account_id} is not a "\
188
- 'valid subdomain.'
189
- end
190
- end
191
-
192
- def validate_region!(arn, region, s3_use_arn_region)
193
- if region.include?('fips')
194
- raise ArgumentError,
195
- 'FIPS client regions are currently not supported with '\
196
- 'accesspoint ARNs.'
197
- end
198
-
199
- if s3_use_arn_region &&
200
- !Aws::Partitions.partition(arn.partition).region?(region)
201
- raise Aws::Errors::InvalidARNPartitionError
202
- end
203
-
204
- if !s3_use_arn_region && region != arn.region
205
- raise Aws::Errors::InvalidARNRegionError
206
- end
207
- end
208
- end
209
- end
210
- end
211
- end
212
- end