fog-aws 3.5.1 → 3.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1e5ec1bf418676b65d208530359ea42646043759948957785d93f49766803490
4
- data.tar.gz: d01633914ad453baeeb3b5da1eaa21880276f4a534a3dd00d28c20cd0c9c1b4f
3
+ metadata.gz: d5fc7b96fe4f26c5af84de803e8af393cee43b14b070a70be68b910da92cb61a
4
+ data.tar.gz: 2002ebf924fb5108475c69fbde9a0861455bb2087a237135781ae9e217adbe40
5
5
  SHA512:
6
- metadata.gz: a1bf1567ddbcaff60e4cf8041586807f055fc28a1d010a373d7038fa1eb83ab84feb42e2595ebeef5b8508fa61ea6a76e9ad22592d0be0ba865b3908ab8633b8
7
- data.tar.gz: 145c2544d2a240f66dd7e85385509812e12b475fccbbb33563321db519584ed18eb35bb9509ddaef2a397ac545578d5f9ebe6202cb4c19fdaa0122cb5267a351
6
+ metadata.gz: 76ee4f98fea0588666c18c65060d063b8a86215c2abcab505ad891411fd0639f449e54806d198973b6d117fc15be2b921b2e8932bc42d57ea11e89068f66b818
7
+ data.tar.gz: 005214de385e9474d415bb3780fbffddce311a552b81c60f3fcbaa67dc7116720d099e76cd69ffa6a41284d021e9b2cb53b14d129ecdc9be735a7128ca7295f6
@@ -218,6 +218,7 @@ module Fog
218
218
 
219
219
  def self.regions
220
220
  @regions ||= [
221
+ 'ap-east-1',
221
222
  'ap-northeast-1', 'ap-northeast-2', 'ap-northeast-3',
222
223
  'ap-south-1',
223
224
  'ap-southeast-1', 'ap-southeast-2',
@@ -25,7 +25,10 @@ module Fog
25
25
  request :list_resource_record_sets
26
26
  request :get_change
27
27
 
28
+
28
29
  class Mock
30
+ include Fog::AWS::CredentialFetcher::ConnectionMethods
31
+
29
32
  def self.data
30
33
  @data ||= Hash.new do |hash, region|
31
34
  hash[region] = Hash.new do |region_hash, key|
@@ -70,6 +73,7 @@ module Fog
70
73
 
71
74
  class Real
72
75
  include Fog::AWS::CredentialFetcher::ConnectionMethods
76
+
73
77
  # Initialize connection to Route 53 DNS service
74
78
  #
75
79
  # ==== Notes
@@ -160,6 +164,138 @@ module Fog
160
164
  Base64.encode64(signed_string).chomp!
161
165
  end
162
166
  end
167
+
168
+ def self.hosted_zone_for_alias_target(dns_name)
169
+ hosted_zones = if dns_name.match(/^dualstack\./)
170
+ elb_dualstack_hosted_zone_mapping
171
+ else
172
+ elb_hosted_zone_mapping
173
+ end
174
+
175
+ Hash[hosted_zones.select { |k, _|
176
+ dns_name =~ /\A.+\.#{k}\.elb\.amazonaws\.com\.?\z/
177
+ }].values.last
178
+ end
179
+
180
+ def self.elb_hosted_zone_mapping
181
+ @elb_hosted_zone_mapping ||= {
182
+ "ap-northeast-1" => "Z2YN17T5R711GT",
183
+ "ap-southeast-1" => "Z1WI8VXHPB1R38",
184
+ "ap-southeast-2" => "Z2999QAZ9SRTIC",
185
+ "eu-west-1" => "Z3NF1Z3NOM5OY2",
186
+ "eu-central-1" => "Z215JYRZR1TBD5",
187
+ "sa-east-1" => "Z2ES78Y61JGQKS",
188
+ "us-east-1" => "Z3DZXE0Q79N41H",
189
+ "us-west-1" => "Z1M58G0W56PQJA",
190
+ "us-west-2" => "Z33MTJ483KN6FU",
191
+ }
192
+ end
193
+
194
+ # See https://docs.aws.amazon.com/general/latest/gr/rande.html#elb_region
195
+ # This needs to be kept in sync manually sadly for now as seemingly this data is not available via an API
196
+ def self.elb_dualstack_hosted_zone_mapping
197
+ @elb_dualstack_hosted_zone_mapping ||= {
198
+ "ap-northeast-1" => "Z14GRHDCWA56QT",
199
+ "ap-northeast-2" => "ZWKZPGTI48KDX",
200
+ "ap-northeast-3" => "Z5LXEXXYW11ES",
201
+ "ap-south-1" => "ZP97RAFLXTNZK",
202
+ "ap-southeast-1" => "Z1LMS91P8CMLE5",
203
+ "ap-southeast-2" => "Z1GM3OXH4ZPM65",
204
+ "ca-central-1" => "ZQSVJUPU6J1EY",
205
+ "eu-central-1" => "Z215JYRZR1TBD5",
206
+ "eu-west-1" => "Z32O12XQLNTSW2",
207
+ "eu-west-2" => "ZHURV8PSTC4K8",
208
+ "eu-west-3" => "Z3Q77PNBQS71R4",
209
+ "us-east-1" => "Z35SXDOTRQ7X7K",
210
+ "us-east-2" => "Z3AADJGX6KTTL2",
211
+ "us-west-1" => "Z368ELLRRE2KJ0",
212
+ "us-west-2" => "Z1H1FL5HABSF5",
213
+ "sa-east-1" => "Z2P70J7HTTTPLU",
214
+ }
215
+ end
216
+
217
+ # Returns the xml request for a given changeset
218
+ def self.change_resource_record_sets_data(zone_id, change_batch, version, options = {})
219
+ # AWS methods return zone_ids that looks like '/hostedzone/id'. Let the caller either use
220
+ # that form or just the actual id (which is what this request needs)
221
+ zone_id = zone_id.sub('/hostedzone/', '')
222
+
223
+ optional_tags = ''
224
+ options.each do |option, value|
225
+ case option
226
+ when :comment
227
+ optional_tags += "<Comment>#{value}</Comment>"
228
+ end
229
+ end
230
+
231
+ #build XML
232
+ if change_batch.count > 0
233
+
234
+ changes = "<ChangeBatch>#{optional_tags}<Changes>"
235
+
236
+ change_batch.each do |change_item|
237
+ action_tag = %Q{<Action>#{change_item[:action]}</Action>}
238
+ name_tag = %Q{<Name>#{change_item[:name]}</Name>}
239
+ type_tag = %Q{<Type>#{change_item[:type]}</Type>}
240
+
241
+ # TTL must be omitted if using an alias record
242
+ ttl_tag = ''
243
+ ttl_tag += %Q{<TTL>#{change_item[:ttl]}</TTL>} unless change_item[:alias_target]
244
+
245
+ weight_tag = ''
246
+ set_identifier_tag = ''
247
+ region_tag = ''
248
+ if change_item[:set_identifier]
249
+ set_identifier_tag += %Q{<SetIdentifier>#{change_item[:set_identifier]}</SetIdentifier>}
250
+ if change_item[:weight] # Weighted Record
251
+ weight_tag += %Q{<Weight>#{change_item[:weight]}</Weight>}
252
+ elsif change_item[:region] # Latency record
253
+ region_tag += %Q{<Region>#{change_item[:region]}</Region>}
254
+ end
255
+ end
256
+
257
+ failover_tag = if change_item[:failover]
258
+ %Q{<Failover>#{change_item[:failover]}</Failover>}
259
+ end
260
+
261
+ geolocation_tag = if change_item[:geo_location]
262
+ xml_geo = change_item[:geo_location].map { |k,v| "<#{k}>#{v}</#{k}>" }.join
263
+ %Q{<GeoLocation>#{xml_geo}</GeoLocation>}
264
+ end
265
+
266
+ resource_records = change_item[:resource_records] || []
267
+ resource_record_tags = ''
268
+ resource_records.each do |record|
269
+ resource_record_tags += %Q{<ResourceRecord><Value>#{record}</Value></ResourceRecord>}
270
+ end
271
+
272
+ # ResourceRecords must be omitted if using an alias record
273
+ resource_tag = ''
274
+ resource_tag += %Q{<ResourceRecords>#{resource_record_tags}</ResourceRecords>} if resource_records.any?
275
+
276
+ alias_target_tag = ''
277
+ if change_item[:alias_target]
278
+ # Accept either underscore or camel case for hash keys.
279
+ dns_name = change_item[:alias_target][:dns_name] || change_item[:alias_target][:DNSName]
280
+ hosted_zone_id = change_item[:alias_target][:hosted_zone_id] || change_item[:alias_target][:HostedZoneId] || AWS.hosted_zone_for_alias_target(dns_name)
281
+ evaluate_target_health = change_item[:alias_target][:evaluate_target_health] || change_item[:alias_target][:EvaluateTargetHealth] || false
282
+ evaluate_target_health_xml = !evaluate_target_health.nil? ? %Q{<EvaluateTargetHealth>#{evaluate_target_health}</EvaluateTargetHealth>} : ''
283
+ alias_target_tag += %Q{<AliasTarget><HostedZoneId>#{hosted_zone_id}</HostedZoneId><DNSName>#{dns_name}</DNSName>#{evaluate_target_health_xml}</AliasTarget>}
284
+ end
285
+
286
+ health_check_id_tag = if change_item[:health_check_id]
287
+ %Q{<HealthCheckId>#{change_item[:health_check_id]}</HealthCheckId>}
288
+ end
289
+
290
+ change_tags = %Q{<Change>#{action_tag}<ResourceRecordSet>#{name_tag}#{type_tag}#{set_identifier_tag}#{weight_tag}#{region_tag}#{failover_tag}#{geolocation_tag}#{ttl_tag}#{resource_tag}#{alias_target_tag}#{health_check_id_tag}</ResourceRecordSet></Change>}
291
+ changes += change_tags
292
+ end
293
+
294
+ changes += '</Changes></ChangeBatch>'
295
+ end
296
+
297
+ %Q{<?xml version="1.0" encoding="UTF-8"?><ChangeResourceRecordSetsRequest xmlns="https://route53.amazonaws.com/doc/#{version}/">#{changes}</ChangeResourceRecordSetsRequest>}
298
+ end
163
299
  end
164
300
  end
165
301
 
@@ -1,139 +1,6 @@
1
1
  module Fog
2
2
  module AWS
3
3
  class DNS
4
-
5
- def self.hosted_zone_for_alias_target(dns_name)
6
- hosted_zones = if dns_name.match(/^dualstack\./)
7
- elb_dualstack_hosted_zone_mapping
8
- else
9
- elb_hosted_zone_mapping
10
- end
11
-
12
- Hash[hosted_zones.select { |k, _|
13
- dns_name =~ /\A.+\.#{k}\.elb\.amazonaws\.com\.?\z/
14
- }].values.last
15
- end
16
-
17
- def self.elb_hosted_zone_mapping
18
- @elb_hosted_zone_mapping ||= {
19
- "ap-northeast-1" => "Z2YN17T5R711GT",
20
- "ap-southeast-1" => "Z1WI8VXHPB1R38",
21
- "ap-southeast-2" => "Z2999QAZ9SRTIC",
22
- "eu-west-1" => "Z3NF1Z3NOM5OY2",
23
- "eu-central-1" => "Z215JYRZR1TBD5",
24
- "sa-east-1" => "Z2ES78Y61JGQKS",
25
- "us-east-1" => "Z3DZXE0Q79N41H",
26
- "us-west-1" => "Z1M58G0W56PQJA",
27
- "us-west-2" => "Z33MTJ483KN6FU",
28
- }
29
- end
30
-
31
- # See https://docs.aws.amazon.com/general/latest/gr/rande.html#elb_region
32
- # This needs to be kept in sync manually sadly for now as seemingly this data is not available via an API
33
- def self.elb_dualstack_hosted_zone_mapping
34
- @elb_dualstack_hosted_zone_mapping ||= {
35
- "ap-northeast-1" => "Z14GRHDCWA56QT",
36
- "ap-northeast-2" => "ZWKZPGTI48KDX",
37
- "ap-northeast-3" => "Z5LXEXXYW11ES",
38
- "ap-south-1" => "ZP97RAFLXTNZK",
39
- "ap-southeast-1" => "Z1LMS91P8CMLE5",
40
- "ap-southeast-2" => "Z1GM3OXH4ZPM65",
41
- "ca-central-1" => "ZQSVJUPU6J1EY",
42
- "eu-central-1" => "Z215JYRZR1TBD5",
43
- "eu-west-1" => "Z32O12XQLNTSW2",
44
- "eu-west-2" => "ZHURV8PSTC4K8",
45
- "eu-west-3" => "Z3Q77PNBQS71R4",
46
- "us-east-1" => "Z35SXDOTRQ7X7K",
47
- "us-east-2" => "Z3AADJGX6KTTL2",
48
- "us-west-1" => "Z368ELLRRE2KJ0",
49
- "us-west-2" => "Z1H1FL5HABSF5",
50
- "sa-east-1" => "Z2P70J7HTTTPLU",
51
- }
52
- end
53
-
54
- # Returns the xml request for a given changeset
55
- def self.change_resource_record_sets_data(zone_id, change_batch, version, options = {})
56
- # AWS methods return zone_ids that looks like '/hostedzone/id'. Let the caller either use
57
- # that form or just the actual id (which is what this request needs)
58
- zone_id = zone_id.sub('/hostedzone/', '')
59
-
60
- optional_tags = ''
61
- options.each do |option, value|
62
- case option
63
- when :comment
64
- optional_tags += "<Comment>#{value}</Comment>"
65
- end
66
- end
67
-
68
- #build XML
69
- if change_batch.count > 0
70
-
71
- changes = "<ChangeBatch>#{optional_tags}<Changes>"
72
-
73
- change_batch.each do |change_item|
74
- action_tag = %Q{<Action>#{change_item[:action]}</Action>}
75
- name_tag = %Q{<Name>#{change_item[:name]}</Name>}
76
- type_tag = %Q{<Type>#{change_item[:type]}</Type>}
77
-
78
- # TTL must be omitted if using an alias record
79
- ttl_tag = ''
80
- ttl_tag += %Q{<TTL>#{change_item[:ttl]}</TTL>} unless change_item[:alias_target]
81
-
82
- weight_tag = ''
83
- set_identifier_tag = ''
84
- region_tag = ''
85
- if change_item[:set_identifier]
86
- set_identifier_tag += %Q{<SetIdentifier>#{change_item[:set_identifier]}</SetIdentifier>}
87
- if change_item[:weight] # Weighted Record
88
- weight_tag += %Q{<Weight>#{change_item[:weight]}</Weight>}
89
- elsif change_item[:region] # Latency record
90
- region_tag += %Q{<Region>#{change_item[:region]}</Region>}
91
- end
92
- end
93
-
94
- failover_tag = if change_item[:failover]
95
- %Q{<Failover>#{change_item[:failover]}</Failover>}
96
- end
97
-
98
- geolocation_tag = if change_item[:geo_location]
99
- xml_geo = change_item[:geo_location].map { |k,v| "<#{k}>#{v}</#{k}>" }.join
100
- %Q{<GeoLocation>#{xml_geo}</GeoLocation>}
101
- end
102
-
103
- resource_records = change_item[:resource_records] || []
104
- resource_record_tags = ''
105
- resource_records.each do |record|
106
- resource_record_tags += %Q{<ResourceRecord><Value>#{record}</Value></ResourceRecord>}
107
- end
108
-
109
- # ResourceRecords must be omitted if using an alias record
110
- resource_tag = ''
111
- resource_tag += %Q{<ResourceRecords>#{resource_record_tags}</ResourceRecords>} if resource_records.any?
112
-
113
- alias_target_tag = ''
114
- if change_item[:alias_target]
115
- # Accept either underscore or camel case for hash keys.
116
- dns_name = change_item[:alias_target][:dns_name] || change_item[:alias_target][:DNSName]
117
- hosted_zone_id = change_item[:alias_target][:hosted_zone_id] || change_item[:alias_target][:HostedZoneId] || AWS.hosted_zone_for_alias_target(dns_name)
118
- evaluate_target_health = change_item[:alias_target][:evaluate_target_health] || change_item[:alias_target][:EvaluateTargetHealth] || false
119
- evaluate_target_health_xml = !evaluate_target_health.nil? ? %Q{<EvaluateTargetHealth>#{evaluate_target_health}</EvaluateTargetHealth>} : ''
120
- alias_target_tag += %Q{<AliasTarget><HostedZoneId>#{hosted_zone_id}</HostedZoneId><DNSName>#{dns_name}</DNSName>#{evaluate_target_health_xml}</AliasTarget>}
121
- end
122
-
123
- health_check_id_tag = if change_item[:health_check_id]
124
- %Q{<HealthCheckId>#{change_item[:health_check_id]}</HealthCheckId>}
125
- end
126
-
127
- change_tags = %Q{<Change>#{action_tag}<ResourceRecordSet>#{name_tag}#{type_tag}#{set_identifier_tag}#{weight_tag}#{region_tag}#{failover_tag}#{geolocation_tag}#{ttl_tag}#{resource_tag}#{alias_target_tag}#{health_check_id_tag}</ResourceRecordSet></Change>}
128
- changes += change_tags
129
- end
130
-
131
- changes += '</Changes></ChangeBatch>'
132
- end
133
-
134
- %Q{<?xml version="1.0" encoding="UTF-8"?><ChangeResourceRecordSetsRequest xmlns="https://route53.amazonaws.com/doc/#{version}/">#{changes}</ChangeResourceRecordSetsRequest>}
135
- end
136
-
137
4
  class Real
138
5
  require 'fog/aws/parsers/dns/change_resource_record_sets'
139
6
 
@@ -4,7 +4,7 @@ module Fog
4
4
  module SharedMockMethods
5
5
  def define_mock_acl(bucket_name, object_name, options)
6
6
  acl = options['x-amz-acl'] || 'private'
7
- if !['private', 'public-read', 'public-read-write', 'authenticated-read'].include?(acl)
7
+ if !['private', 'public-read', 'public-read-write', 'authenticated-read', 'bucket-owner-read', 'bucket-owner-full-control'].include?(acl)
8
8
  raise Excon::Errors::BadRequest.new('invalid x-amz-acl')
9
9
  else
10
10
  self.data[:acls][:object][bucket_name] ||= {}
@@ -43,7 +43,7 @@ module Fog
43
43
  ]
44
44
 
45
45
  requires :aws_access_key_id, :aws_secret_access_key
46
- recognizes :endpoint, :region, :host, :port, :scheme, :persistent, :use_iam_profile, :aws_session_token, :aws_credentials_expire_at, :path_style, :acceleration, :instrumentor, :instrumentor_name, :aws_signature_version, :virtual_host, :cname
46
+ recognizes :endpoint, :region, :host, :port, :scheme, :persistent, :use_iam_profile, :aws_session_token, :aws_credentials_expire_at, :path_style, :acceleration, :instrumentor, :instrumentor_name, :aws_signature_version, :enable_signature_v4_streaming, :virtual_host, :cname
47
47
 
48
48
  secrets :aws_secret_access_key, :hmac
49
49
 
@@ -506,6 +506,7 @@ module Fog
506
506
  @persistent = options.fetch(:persistent, false)
507
507
  @acceleration = options.fetch(:acceleration, false)
508
508
  @signature_version = options.fetch(:aws_signature_version, 4)
509
+ @enable_signature_v4_streaming = options.fetch(:enable_signature_v4_streaming, true)
509
510
  validate_signature_version!
510
511
  @path_style = options[:path_style] || false
511
512
 
@@ -587,20 +588,24 @@ module Fog
587
588
  if @signature_version == 4
588
589
  params[:headers]['x-amz-date'] = date.to_iso8601_basic
589
590
  if params[:body].respond_to?(:read)
590
- # See http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-streaming.html
591
- # We ignore the bit about setting the content-encoding to aws-chunked because
592
- # this can cause s3 to serve files with a blank content encoding which causes problems with some CDNs
593
- # AWS have confirmed that s3 can infer that the content-encoding is aws-chunked from the x-amz-content-sha256 header
594
- #
595
- params[:headers]['x-amz-content-sha256'] = 'STREAMING-AWS4-HMAC-SHA256-PAYLOAD'
596
- params[:headers]['x-amz-decoded-content-length'] = params[:headers].delete 'Content-Length'
591
+ if @enable_signature_v4_streaming
592
+ # See http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-streaming.html
593
+ # We ignore the bit about setting the content-encoding to aws-chunked because
594
+ # this can cause s3 to serve files with a blank content encoding which causes problems with some CDNs
595
+ # AWS have confirmed that s3 can infer that the content-encoding is aws-chunked from the x-amz-content-sha256 header
596
+ #
597
+ params[:headers]['x-amz-content-sha256'] = 'STREAMING-AWS4-HMAC-SHA256-PAYLOAD'
598
+ params[:headers]['x-amz-decoded-content-length'] = params[:headers].delete 'Content-Length'
599
+ else
600
+ params[:headers]['x-amz-content-sha256'] = 'UNSIGNED-PAYLOAD'
601
+ end
597
602
  else
598
603
  params[:headers]['x-amz-content-sha256'] ||= OpenSSL::Digest::SHA256.hexdigest(params[:body] || '')
599
604
  end
600
605
  signature_components = @signer.signature_components(params, date, params[:headers]['x-amz-content-sha256'])
601
606
  params[:headers]['Authorization'] = @signer.components_to_header(signature_components)
602
607
 
603
- if params[:body].respond_to?(:read)
608
+ if params[:body].respond_to?(:read) && @enable_signature_v4_streaming
604
609
  body = params.delete :body
605
610
  params[:request_block] = S3Streamer.new(body, signature_components['X-Amz-Signature'], @signer, date)
606
611
  end
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module AWS
3
- VERSION = "3.5.1"
3
+ VERSION = "3.5.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-aws
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.1
4
+ version: 3.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Lane
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-06-10 00:00:00.000000000 Z
12
+ date: 2019-07-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -1718,7 +1718,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1718
1718
  - !ruby/object:Gem::Version
1719
1719
  version: '0'
1720
1720
  requirements: []
1721
- rubygems_version: 3.0.2
1721
+ rubygems_version: 3.0.4
1722
1722
  signing_key:
1723
1723
  specification_version: 4
1724
1724
  summary: Module for the 'fog' gem to support Amazon Web Services.