configure-s3-website 1.7.5 → 2.0.0.pre.RC1
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/changelog.md +34 -0
- data/lib/configure-s3-website/cloudfront_client.rb +91 -119
- data/lib/configure-s3-website/version.rb +1 -1
- data/spec/cloudfront_client_spec.rb +120 -70
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4eb8cd23cd38b0f3330c3917994b6d2ebfff0b0d
|
4
|
+
data.tar.gz: d94e2faca53f693abc671f839b8ac4b8525119fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2432f7a98b9c751a920037c54e015a48a096fffc36aaff2713b1b63e1a1f8232a58a0ed918e35327619d23bbe77a668eb92b60f9187838b5d1e782078ae5f3a7
|
7
|
+
data.tar.gz: b66e343138433203ec72d781d286c10d374ab560860c39419c556ba75b9ccdb84527ddcfcd8e92d565dea326d6b6da66d4b0754959a2b1c08e179d65b64a04fd
|
data/changelog.md
CHANGED
@@ -2,6 +2,40 @@
|
|
2
2
|
|
3
3
|
This project uses [Semantic Versioning](http://semver.org).
|
4
4
|
|
5
|
+
## Next
|
6
|
+
|
7
|
+
### Breaking changes
|
8
|
+
|
9
|
+
Since the CloudFront integration now uses the official Ruby AWS SDK, the
|
10
|
+
accepted format of the `cloudfront_distribution_config` is slightly different.
|
11
|
+
|
12
|
+
Below are some examples of changes that you have to perform, depending on the
|
13
|
+
contents of your `cloudfront_distribution_config` setting.
|
14
|
+
|
15
|
+
* Rename `min_TTL` -> `min_ttl`
|
16
|
+
* Change
|
17
|
+
|
18
|
+
```yaml
|
19
|
+
aliases:
|
20
|
+
quantity: 1
|
21
|
+
items:
|
22
|
+
CNAME: my.site.net
|
23
|
+
```
|
24
|
+
|
25
|
+
to
|
26
|
+
|
27
|
+
```yaml
|
28
|
+
aliases:
|
29
|
+
quantity: 1
|
30
|
+
items:
|
31
|
+
- my.site.net
|
32
|
+
```
|
33
|
+
|
34
|
+
* There might be other incompatible settings in your old configuration, but
|
35
|
+
should them exist, the AWS SDK client will print you a helpful error and then
|
36
|
+
safely exit. If this happens, just fix the problems that client reports and
|
37
|
+
try again.
|
38
|
+
|
5
39
|
## 1.7.5
|
6
40
|
|
7
41
|
* Fix CreateBucket broken in 1.7.4
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require "
|
2
|
-
require
|
1
|
+
require "aws-sdk"
|
2
|
+
require 'deep_merge'
|
3
3
|
|
4
4
|
module ConfigureS3Website
|
5
5
|
class CloudFrontClient
|
@@ -7,40 +7,28 @@ module ConfigureS3Website
|
|
7
7
|
config_source = options[:config_source]
|
8
8
|
puts "Detected an existing CloudFront distribution (id #{config_source.cloudfront_distribution_id}) ..."
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
method = Net::HTTP::Get,
|
14
|
-
body = '',
|
15
|
-
config_source
|
16
|
-
)
|
17
|
-
etag = response['ETag']
|
18
|
-
caller_reference = REXML::XPath.first(
|
19
|
-
REXML::Document.new(response.body),
|
20
|
-
'/DistributionConfig/CallerReference'
|
21
|
-
).get_text.to_s
|
10
|
+
live_config = cloudfront(config_source).get_distribution({
|
11
|
+
id: options[:config_source].cloudfront_distribution_id
|
12
|
+
})
|
22
13
|
|
23
|
-
# Call the PUT config resource with the caller reference and ETag
|
24
14
|
custom_distribution_config = config_source.cloudfront_distribution_config || {}
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
custom_distribution_config_with_caller_ref
|
35
|
-
),
|
36
|
-
config_source,
|
37
|
-
headers = { 'If-Match' => etag }
|
15
|
+
if custom_distribution_config.empty?
|
16
|
+
return
|
17
|
+
end
|
18
|
+
live_distribution_config = live_config.distribution.distribution_config.to_hash
|
19
|
+
custom_distribution_config_with_caller_ref = live_distribution_config.deep_merge!(
|
20
|
+
deep_symbolize(custom_distribution_config.merge({
|
21
|
+
caller_reference: live_config.distribution.distribution_config.caller_reference,
|
22
|
+
comment: 'Updated by the configure-s3-website gem'
|
23
|
+
}))
|
38
24
|
)
|
25
|
+
cloudfront(config_source).update_distribution({
|
26
|
+
distribution_config: custom_distribution_config_with_caller_ref,
|
27
|
+
id: options[:config_source].cloudfront_distribution_id,
|
28
|
+
if_match: live_config.etag
|
29
|
+
})
|
39
30
|
|
40
|
-
|
41
|
-
unless custom_distribution_config.empty?
|
42
|
-
print_report_on_custom_distribution_config custom_distribution_config
|
43
|
-
end
|
31
|
+
print_report_on_custom_distribution_config custom_distribution_config_with_caller_ref
|
44
32
|
end
|
45
33
|
|
46
34
|
def self.create_distribution_if_user_agrees(options, standard_input)
|
@@ -59,19 +47,22 @@ module ConfigureS3Website
|
|
59
47
|
|
60
48
|
private
|
61
49
|
|
50
|
+
def self.cloudfront(config_source)
|
51
|
+
Aws::CloudFront::Client.new(
|
52
|
+
region: 'us-east-1',
|
53
|
+
access_key_id: config_source.s3_access_key_id,
|
54
|
+
secret_access_key: config_source.s3_secret_access_key
|
55
|
+
)
|
56
|
+
end
|
57
|
+
|
62
58
|
def self.create_distribution(options)
|
63
59
|
config_source = options[:config_source]
|
64
60
|
custom_distribution_config = config_source.cloudfront_distribution_config || {}
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
config_source
|
71
|
-
).body
|
72
|
-
)
|
73
|
-
dist_id = REXML::XPath.first(response_xml, '/Distribution/Id').get_text
|
74
|
-
print_report_on_new_dist response_xml, dist_id, options, config_source
|
61
|
+
distribution = cloudfront(config_source).create_distribution(
|
62
|
+
deep_symbolize new_distribution_config(config_source, custom_distribution_config)
|
63
|
+
).distribution
|
64
|
+
dist_id = distribution.id
|
65
|
+
print_report_on_new_dist distribution, dist_id, options, config_source
|
75
66
|
config_source.cloudfront_distribution_id = dist_id.to_s
|
76
67
|
puts " Added setting 'cloudfront_distribution_id: #{dist_id}' into #{config_source.description}"
|
77
68
|
unless custom_distribution_config.empty?
|
@@ -88,96 +79,67 @@ module ConfigureS3Website
|
|
88
79
|
gsub(/^/, padding(left_padding))
|
89
80
|
end
|
90
81
|
|
91
|
-
def self.print_report_on_new_dist(
|
82
|
+
def self.print_report_on_new_dist(distribution, dist_id, options, config_source)
|
92
83
|
config_source = options[:config_source]
|
93
|
-
|
94
|
-
s3_website_domain_name = REXML::XPath.first(
|
95
|
-
response_xml,
|
96
|
-
'/Distribution/DistributionConfig/Origins/Items/Origin/DomainName'
|
97
|
-
).get_text
|
98
|
-
puts " The distribution #{dist_id} at #{dist_domain_name} now delivers the origin #{s3_website_domain_name}"
|
84
|
+
puts " The distribution #{dist_id} at #{distribution.domain_name} now delivers the origin #{distribution.distribution_config.origins.items[0].domain_name}"
|
99
85
|
puts ' Please allow up to 15 minutes for the distribution to initialise'
|
100
86
|
puts ' For more information on the distribution, see https://console.aws.amazon.com/cloudfront'
|
101
87
|
if options[:verbose]
|
102
88
|
puts ' Below is the response from the CloudFront API:'
|
103
|
-
|
89
|
+
puts distribution
|
104
90
|
end
|
105
91
|
end
|
106
92
|
|
107
|
-
def self.
|
108
|
-
lines = []
|
109
|
-
response_xml.write(lines, 2)
|
110
|
-
puts lines.join().
|
111
|
-
gsub(/^/, "" + padding(left_padding)).
|
112
|
-
gsub(/\s$/, "")
|
113
|
-
end
|
114
|
-
|
115
|
-
def self.distribution_config_xml(config_source, custom_cf_settings)
|
116
|
-
domain_name = "#{config_source.s3_bucket_name}.#{EndpointHelper.s3_website_hostname(config_source.s3_endpoint)}"
|
117
|
-
%|
|
118
|
-
<DistributionConfig xmlns="http://cloudfront.amazonaws.com/doc/2012-07-01/">
|
119
|
-
<Origins>
|
120
|
-
<Quantity>1</Quantity>
|
121
|
-
<Items>
|
122
|
-
<Origin>
|
123
|
-
<Id>#{origin_id config_source}</Id>
|
124
|
-
<DomainName>#{domain_name}</DomainName>
|
125
|
-
<CustomOriginConfig>
|
126
|
-
<HTTPPort>80</HTTPPort>
|
127
|
-
<HTTPSPort>443</HTTPSPort>
|
128
|
-
<OriginProtocolPolicy>http-only</OriginProtocolPolicy>
|
129
|
-
</CustomOriginConfig>
|
130
|
-
</Origin>
|
131
|
-
</Items>
|
132
|
-
</Origins>
|
133
|
-
#{
|
134
|
-
require 'deep_merge'
|
135
|
-
settings = default_cloudfront_settings config_source
|
136
|
-
settings.deep_merge! custom_cf_settings
|
137
|
-
XmlHelper.hash_to_api_xml(settings)
|
138
|
-
}
|
139
|
-
</DistributionConfig>
|
140
|
-
|
|
141
|
-
end
|
142
|
-
|
143
|
-
# Changing these default settings probably necessitates a
|
144
|
-
# backward incompatible release.
|
145
|
-
#
|
146
|
-
# If you change these settings, remember to update also the README.md.
|
147
|
-
def self.default_cloudfront_settings(config_source)
|
93
|
+
def self.new_distribution_config(config_source, custom_cf_settings)
|
148
94
|
{
|
149
|
-
'
|
150
|
-
|
151
|
-
|
152
|
-
'
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
95
|
+
'distribution_config' => {
|
96
|
+
'caller_reference' => 'configure-s3-website gem ' + Time.now.to_s,
|
97
|
+
'default_root_object' => 'index.html',
|
98
|
+
'origins' => {
|
99
|
+
'quantity' => 1,
|
100
|
+
'items' => [
|
101
|
+
{
|
102
|
+
'id' => (origin_id config_source),
|
103
|
+
'domain_name' => "#{config_source.s3_bucket_name}.#{EndpointHelper.s3_website_hostname(config_source.s3_endpoint)}",
|
104
|
+
'custom_origin_config' => {
|
105
|
+
'http_port' => 80,
|
106
|
+
'https_port' => 443,
|
107
|
+
'origin_protocol_policy' => 'http-only'
|
108
|
+
}
|
109
|
+
}
|
110
|
+
]
|
111
|
+
},
|
112
|
+
'logging' => {
|
165
113
|
'enabled' => 'false',
|
114
|
+
'include_cookies' => 'false',
|
115
|
+
'bucket' => '',
|
116
|
+
'prefix' => ''
|
117
|
+
},
|
118
|
+
'enabled' => 'true',
|
119
|
+
'comment' => 'Created by the configure-s3-website gem',
|
120
|
+
'aliases' => {
|
166
121
|
'quantity' => '0'
|
167
122
|
},
|
168
|
-
'
|
169
|
-
'
|
170
|
-
'
|
171
|
-
'
|
172
|
-
|
123
|
+
'default_cache_behavior' => {
|
124
|
+
'target_origin_id' => (origin_id config_source),
|
125
|
+
'trusted_signers' => {
|
126
|
+
'enabled' => 'false',
|
127
|
+
'quantity' => '0'
|
128
|
+
},
|
129
|
+
'forwarded_values' => {
|
130
|
+
'query_string' => 'true',
|
131
|
+
'cookies' => {
|
132
|
+
'forward' => 'all'
|
133
|
+
}
|
134
|
+
},
|
135
|
+
'viewer_protocol_policy' => 'allow-all',
|
136
|
+
'min_ttl' => '86400'
|
173
137
|
},
|
174
|
-
'
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
},
|
180
|
-
'price_class' => 'PriceClass_All'
|
138
|
+
'cache_behaviors' => {
|
139
|
+
'quantity' => '0'
|
140
|
+
},
|
141
|
+
'price_class' => 'PriceClass_All'
|
142
|
+
}.deep_merge!(custom_cf_settings)
|
181
143
|
}
|
182
144
|
end
|
183
145
|
|
@@ -190,5 +152,15 @@ module ConfigureS3Website
|
|
190
152
|
amount.times { padding << " " }
|
191
153
|
padding
|
192
154
|
end
|
155
|
+
|
156
|
+
def self.deep_symbolize(value)
|
157
|
+
if value.is_a? Hash
|
158
|
+
Hash[value.map { |k,v| [k.to_sym, deep_symbolize(v)] }]
|
159
|
+
elsif value.is_a? Array
|
160
|
+
value.map { |v| deep_symbolize(v) }
|
161
|
+
else
|
162
|
+
value
|
163
|
+
end
|
164
|
+
end
|
193
165
|
end
|
194
166
|
end
|
@@ -1,88 +1,138 @@
|
|
1
1
|
require 'rspec'
|
2
2
|
require 'configure-s3-website'
|
3
|
-
require "rexml/document"
|
4
|
-
require "rexml/xpath"
|
5
3
|
|
6
4
|
describe ConfigureS3Website::CloudFrontClient do
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
allow(mock).to receive(:s3_endpoint).and_return(nil)
|
13
|
-
mock
|
14
|
-
}
|
5
|
+
RSpec::Matchers.define :lambda_matcher do |lmbda, expected_value|
|
6
|
+
match { |create_distribution_args|
|
7
|
+
lmbda.call(create_distribution_args) == expected_value
|
8
|
+
}
|
9
|
+
end
|
15
10
|
|
16
|
-
|
17
|
-
|
18
|
-
|
11
|
+
def config_source_mock(cloudfront_distribution_config, region)
|
12
|
+
mock = double('config_source')
|
13
|
+
allow(mock).to receive(:s3_bucket_name).and_return('test-bucket')
|
14
|
+
allow(mock).to receive(:s3_endpoint).and_return(region)
|
15
|
+
allow(mock).to receive(:s3_access_key_id).and_return('foo')
|
16
|
+
allow(mock).to receive(:s3_secret_access_key).and_return('bar')
|
17
|
+
allow(mock).to receive(:cloudfront_distribution_id).and_return('AEEEE')
|
18
|
+
allow(mock).to receive(:cloudfront_distribution_id=).with(anything).and_return(nil)
|
19
|
+
allow(mock).to receive(:description)
|
20
|
+
allow(mock).to receive(:cloudfront_distribution_config).and_return(cloudfront_distribution_config)
|
21
|
+
mock
|
22
|
+
end
|
19
23
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
let(:aws_cloudfront_client) {
|
25
|
+
cloudfront_client = double('cloudfront_client')
|
26
|
+
create_distribution_response = double('create_dist_response')
|
27
|
+
allow(create_distribution_response).to receive_message_chain(:distribution, :id) { 'bar' }
|
28
|
+
allow(create_distribution_response).to receive_message_chain(:distribution, :domain_name) { 'foo' }
|
29
|
+
allow(create_distribution_response).to receive_message_chain(:distribution, :distribution_config, :origins, :items) {
|
30
|
+
[double( :domain_name => 'foo' )]
|
31
|
+
}
|
32
|
+
allow(cloudfront_client).to receive(:create_distribution).and_return(create_distribution_response)
|
33
|
+
get_distribution_response = double('get_distribution_response')
|
34
|
+
allow(get_distribution_response).to receive(:etag).and_return('tag')
|
35
|
+
allow(get_distribution_response).to receive_message_chain(:distribution, :distribution_config).and_return({
|
36
|
+
:default_cache_behavior => {
|
37
|
+
:viewer_protocol_policy => 'allow_all',
|
38
|
+
:min_ttl => 5000
|
39
|
+
}
|
40
|
+
})
|
41
|
+
allow(get_distribution_response).to receive_message_chain(:distribution, :distribution_config, :caller_reference) { 'ref' }
|
42
|
+
allow(cloudfront_client).to receive(:get_distribution).with(:id => 'AEEEE').and_return(get_distribution_response)
|
43
|
+
cloudfront_client
|
44
|
+
}
|
45
|
+
before {
|
46
|
+
allow(ConfigureS3Website::CloudFrontClient).to receive(:cloudfront).and_return(aws_cloudfront_client)
|
47
|
+
}
|
48
|
+
describe 'letting the user to override the default values' do
|
49
|
+
cloudfront_distribution_config = {
|
50
|
+
'default_cache_behavior' => {
|
51
|
+
'min_ttl' => 900
|
28
52
|
}
|
53
|
+
}
|
29
54
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
55
|
+
context "update distribution" do
|
56
|
+
it "let's the user to override the default ttl" do
|
57
|
+
expect(aws_cloudfront_client).to receive(:update_distribution).with(
|
58
|
+
lambda_matcher(lambda { |update_distribution_args|
|
59
|
+
update_distribution_args[:distribution_config][:default_cache_behavior][:min_ttl]
|
60
|
+
}, 900)
|
61
|
+
)
|
62
|
+
ConfigureS3Website::CloudFrontClient.send(
|
63
|
+
:apply_distribution_config,
|
64
|
+
{:config_source => config_source_mock(cloudfront_distribution_config, region = 'something') }
|
65
|
+
)
|
35
66
|
end
|
36
67
|
|
37
68
|
it 'retains the default values that are not overriden' do
|
38
|
-
expect(
|
39
|
-
|
40
|
-
|
41
|
-
|
69
|
+
expect(aws_cloudfront_client).to receive(:update_distribution).with(
|
70
|
+
lambda_matcher(lambda { |update_distribution_args|
|
71
|
+
update_distribution_args[:distribution_config][:default_cache_behavior][:viewer_protocol_policy]
|
72
|
+
}, 'allow_all')
|
73
|
+
)
|
74
|
+
ConfigureS3Website::CloudFrontClient.send(
|
75
|
+
:apply_distribution_config,
|
76
|
+
{:config_source => config_source_mock(cloudfront_distribution_config, region = 'something') }
|
77
|
+
)
|
42
78
|
end
|
43
79
|
end
|
44
80
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
{ :region => 'sa-east-1', :website_endpoint => 's3-website-sa-east-1.amazonaws.com' },
|
57
|
-
].each { |conf|
|
58
|
-
region = conf[:region]
|
59
|
-
website_endpoint = conf[:website_endpoint]
|
60
|
-
describe "inferring //Origins/Items/Origin/DomainName (#{region})" do
|
61
|
-
let(:config_source) {
|
62
|
-
mock = double('config_source')
|
63
|
-
allow(mock).to receive(:s3_bucket_name).and_return('test-bucket')
|
64
|
-
allow(mock).to receive(:s3_endpoint).and_return(region)
|
65
|
-
mock
|
66
|
-
}
|
67
|
-
|
68
|
-
let(:distribution_config_xml) {
|
69
|
-
REXML::Document.new(
|
70
|
-
ConfigureS3Website::CloudFrontClient.send(
|
71
|
-
:distribution_config_xml,
|
72
|
-
config_source,
|
73
|
-
custom_distribution_config = {}
|
74
|
-
)
|
75
|
-
)
|
76
|
-
}
|
77
|
-
|
78
|
-
it "honors the endpoint of the S3 website (#{region})" do
|
79
|
-
expect(REXML::XPath.first(
|
80
|
-
distribution_config_xml,
|
81
|
-
'/DistributionConfig/Origins/Items/Origin/DomainName'
|
82
|
-
).get_text.to_s).to eq("test-bucket.#{website_endpoint}")
|
83
|
-
end
|
81
|
+
context "create distribution" do
|
82
|
+
it "let's the user to override the default ttl" do
|
83
|
+
expect(aws_cloudfront_client).to receive(:create_distribution).with(
|
84
|
+
lambda_matcher(lambda { |create_distribution_args|
|
85
|
+
create_distribution_args[:distribution_config][:default_cache_behavior][:min_ttl]
|
86
|
+
}, 900)
|
87
|
+
)
|
88
|
+
ConfigureS3Website::CloudFrontClient.send(
|
89
|
+
:create_distribution,
|
90
|
+
{:config_source => config_source_mock(cloudfront_distribution_config, region = 'something') }
|
91
|
+
)
|
84
92
|
end
|
85
|
-
}
|
86
93
|
|
94
|
+
it 'retains the default values that are not overriden' do
|
95
|
+
expect(aws_cloudfront_client).to receive(:create_distribution).with(
|
96
|
+
lambda_matcher(lambda { |create_distribution_args|
|
97
|
+
create_distribution_args[:distribution_config][:default_cache_behavior][:viewer_protocol_policy]
|
98
|
+
}, 'allow-all')
|
99
|
+
)
|
100
|
+
ConfigureS3Website::CloudFrontClient.send(
|
101
|
+
:create_distribution,
|
102
|
+
{:config_source => config_source_mock(cloudfront_distribution_config, region = 'something') }
|
103
|
+
)
|
104
|
+
end
|
105
|
+
end
|
87
106
|
end
|
107
|
+
|
108
|
+
[
|
109
|
+
{ :region => 'us-east-1', :website_endpoint => 's3-website-us-east-1.amazonaws.com' },
|
110
|
+
{ :region => 'us-west-1', :website_endpoint => 's3-website-us-west-1.amazonaws.com' },
|
111
|
+
{ :region => 'us-west-2', :website_endpoint => 's3-website-us-west-2.amazonaws.com' },
|
112
|
+
{ :region => 'ap-south-1', :website_endpoint => 's3-website.ap-south-1.amazonaws.com' },
|
113
|
+
{ :region => 'ap-northeast-2', :website_endpoint => 's3-website.ap-northeast-2.amazonaws.com' },
|
114
|
+
{ :region => 'ap-southeast-1', :website_endpoint => 's3-website-ap-southeast-1.amazonaws.com' },
|
115
|
+
{ :region => 'ap-southeast-2', :website_endpoint => 's3-website-ap-southeast-2.amazonaws.com' },
|
116
|
+
{ :region => 'ap-northeast-1', :website_endpoint => 's3-website-ap-northeast-1.amazonaws.com' },
|
117
|
+
{ :region => 'eu-central-1', :website_endpoint => 's3-website.eu-central-1.amazonaws.com' },
|
118
|
+
{ :region => 'eu-west-1', :website_endpoint => 's3-website-eu-west-1.amazonaws.com' },
|
119
|
+
{ :region => 'sa-east-1', :website_endpoint => 's3-website-sa-east-1.amazonaws.com' },
|
120
|
+
].each { |conf|
|
121
|
+
region = conf[:region]
|
122
|
+
website_endpoint = conf[:website_endpoint]
|
123
|
+
|
124
|
+
describe "create distribution in #{region}" do
|
125
|
+
it "honors the endpoint of the S3 website (#{region})" do
|
126
|
+
expect(aws_cloudfront_client).to receive(:create_distribution).with(
|
127
|
+
lambda_matcher(lambda { |create_distribution_args|
|
128
|
+
create_distribution_args[:distribution_config][:origins][:items][0][:domain_name]
|
129
|
+
}, "test-bucket.#{website_endpoint}")
|
130
|
+
)
|
131
|
+
ConfigureS3Website::CloudFrontClient.send(
|
132
|
+
:create_distribution,
|
133
|
+
{:config_source => config_source_mock({}, region = region) }
|
134
|
+
)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
}
|
88
138
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: configure-s3-website
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0.pre.RC1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lauri Lehmijoki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09
|
11
|
+
date: 2016-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deep_merge
|
@@ -131,12 +131,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
131
131
|
version: '0'
|
132
132
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
133
|
requirements:
|
134
|
-
- - "
|
134
|
+
- - ">"
|
135
135
|
- !ruby/object:Gem::Version
|
136
|
-
version:
|
136
|
+
version: 1.3.1
|
137
137
|
requirements: []
|
138
138
|
rubyforge_project:
|
139
|
-
rubygems_version: 2.
|
139
|
+
rubygems_version: 2.5.1
|
140
140
|
signing_key:
|
141
141
|
specification_version: 4
|
142
142
|
summary: Configure your AWS S3 bucket to function as a web site
|