kumogata-template 0.0.14 → 0.0.15
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/.travis.yml +1 -1
- data/Gemfile.lock +21 -44
- data/README.md +1 -10
- data/bin/kumogata-template +2 -2
- data/kumogata-template.gemspec +6 -5
- data/lib/kumogata/template.rb +1 -0
- data/lib/kumogata/template/cloudfront.rb +306 -0
- data/lib/kumogata/template/ext/kumogata.rb +40 -41
- data/lib/kumogata/template/ext/{argument_parser.rb → option_parser.rb} +2 -2
- data/lib/kumogata/template/s3.rb +7 -7
- data/lib/kumogata/template/version.rb +1 -1
- data/template/cloudfront-distribution.rb +16 -0
- data/template/cloudwatch-alarm.rb +1 -1
- data/template/ec2-volume.rb +1 -1
- data/template/s3-bucket.rb +6 -2
- data/test/abstract_unit.rb +26 -8
- data/test/cloudfront_test.rb +265 -0
- data/test/helper_test.rb +2 -2
- data/test/s3_test.rb +1 -0
- data/test/template/cloudfront-distribution_test.rb +33 -0
- metadata +34 -14
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 805a390615c2e10c71e52f4a908adce0c5fd5535
|
|
4
|
+
data.tar.gz: 5accf023a91f8ac078b4cbaa583ec2a99b97ed94
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 13777f040a5328307f9d94d2eea64379fdae3d04a9ff51062b9f7f3246fcde441d2639fd4f559476c1978c6d1c2d89bbc7ad0f9545fd2b7f5c703a8395c27154
|
|
7
|
+
data.tar.gz: cb64778a6adbffcf55ccc4a5ae729082763c7b4550a60a3c1d47648828dbe6efb412e29e3c60e81c8f27f0c0f5d28fa2b7bc03e8a99aa890cfdbf33d484b9562
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,77 +1,54 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
kumogata-template (0.0.
|
|
5
|
-
aws-sdk (~> 2
|
|
6
|
-
|
|
4
|
+
kumogata-template (0.0.14)
|
|
5
|
+
aws-sdk (~> 2)
|
|
6
|
+
kumogata2-plugin-ruby (= 0.1.3)
|
|
7
|
+
kumogata2-plugin-yaml (= 0.0.1)
|
|
7
8
|
|
|
8
9
|
GEM
|
|
9
10
|
remote: https://rubygems.org/
|
|
10
11
|
specs:
|
|
11
|
-
aws-sdk (2.
|
|
12
|
-
aws-sdk-resources (= 2.
|
|
13
|
-
aws-sdk-core (2.
|
|
12
|
+
aws-sdk (2.7.3)
|
|
13
|
+
aws-sdk-resources (= 2.7.3)
|
|
14
|
+
aws-sdk-core (2.7.3)
|
|
14
15
|
aws-sigv4 (~> 1.0)
|
|
15
16
|
jmespath (~> 1.0)
|
|
16
|
-
aws-sdk-resources (2.
|
|
17
|
-
aws-sdk-core (= 2.
|
|
18
|
-
aws-sdk-v1 (1.66.0)
|
|
19
|
-
json (~> 1.4)
|
|
20
|
-
nokogiri (>= 1.4.4)
|
|
17
|
+
aws-sdk-resources (2.7.3)
|
|
18
|
+
aws-sdk-core (= 2.7.3)
|
|
21
19
|
aws-sigv4 (1.0.0)
|
|
22
20
|
coderay (1.1.1)
|
|
23
|
-
coffee-script (2.4.1)
|
|
24
|
-
coffee-script-source
|
|
25
|
-
execjs
|
|
26
|
-
coffee-script-source (1.12.2)
|
|
27
21
|
diffy (3.1.0)
|
|
28
|
-
dslh (0.
|
|
29
|
-
execjs (2.7.0)
|
|
22
|
+
dslh (0.4.6)
|
|
30
23
|
hashie (3.4.6)
|
|
31
24
|
highline (1.7.8)
|
|
32
25
|
jmespath (1.3.1)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
kumogata (0.5.10)
|
|
36
|
-
aws-sdk-v1
|
|
26
|
+
kumogata2 (0.1.9)
|
|
27
|
+
aws-sdk (>= 2.3.0)
|
|
37
28
|
coderay
|
|
38
|
-
coffee-script
|
|
39
29
|
diffy
|
|
40
|
-
dslh (>= 0.2.7, < 0.3)
|
|
41
30
|
hashie
|
|
42
31
|
highline
|
|
43
|
-
json
|
|
44
|
-
json5
|
|
45
|
-
net-ssh
|
|
46
|
-
retryable (~> 2.0.0)
|
|
47
32
|
term-ansicolor
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
33
|
+
kumogata2-plugin-ruby (0.1.3)
|
|
34
|
+
dslh (>= 0.3.7)
|
|
35
|
+
kumogata2
|
|
36
|
+
kumogata2-plugin-yaml (0.0.1)
|
|
37
|
+
kumogata2
|
|
52
38
|
minitest (5.10.1)
|
|
53
|
-
|
|
54
|
-
nokogiri (1.7.0.1)
|
|
55
|
-
mini_portile2 (~> 2.1.0)
|
|
56
|
-
rake (11.3.0)
|
|
57
|
-
ref (2.0.0)
|
|
58
|
-
retryable (2.0.4)
|
|
39
|
+
rake (12.0.0)
|
|
59
40
|
term-ansicolor (1.4.0)
|
|
60
41
|
tins (~> 1.0)
|
|
61
|
-
therubyracer (0.12.3)
|
|
62
|
-
libv8 (~> 3.16.14.15)
|
|
63
|
-
ref
|
|
64
42
|
tins (1.13.0)
|
|
65
|
-
uuidtools (2.1.5)
|
|
66
43
|
|
|
67
44
|
PLATFORMS
|
|
68
45
|
ruby
|
|
69
46
|
|
|
70
47
|
DEPENDENCIES
|
|
71
|
-
bundler (~> 1.
|
|
48
|
+
bundler (~> 1.13)
|
|
72
49
|
kumogata-template!
|
|
73
|
-
minitest (~> 5.
|
|
74
|
-
rake (~>
|
|
50
|
+
minitest (~> 5.10)
|
|
51
|
+
rake (~> 12.0)
|
|
75
52
|
|
|
76
53
|
BUNDLED WITH
|
|
77
54
|
1.13.7
|
data/README.md
CHANGED
|
@@ -4,13 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
## About
|
|
6
6
|
|
|
7
|
-
- `kumogate-template` is a template sets for [
|
|
7
|
+
- `kumogate-template` is a template sets for [kumogata2](https://github.com/winebarrel/kumogata2).
|
|
8
8
|
|
|
9
9
|
## Installation
|
|
10
10
|
|
|
11
|
-
Add
|
|
12
|
-
|
|
13
|
-
|
|
14
11
|
Add this line to your application's Gemfile:
|
|
15
12
|
|
|
16
13
|
```ruby
|
|
@@ -196,9 +193,3 @@ EOS
|
|
|
196
193
|
- AWS::S3::Bucket
|
|
197
194
|
- AWS::SNS::Topic
|
|
198
195
|
- AWS::SQS::Queue
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
## TODO
|
|
202
|
-
|
|
203
|
-
- Support [Kumogata2](https://github.com/winebarrel/kumogata2)
|
|
204
|
-
- Useful kumogate-template snippets
|
data/bin/kumogata-template
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
$: << File.expand_path("#{File.dirname __FILE__}/../lib")
|
|
3
3
|
require 'rubygems'
|
|
4
4
|
require 'kumogata/template/ext/kumogata'
|
|
5
|
-
require 'kumogata/template/ext/
|
|
5
|
+
require 'kumogata/template/ext/option_parser'
|
|
6
6
|
require 'kumogata/template'
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
load Gem.bin_path('
|
|
9
|
+
load Gem.bin_path('kumogata2', 'kumogata2')
|
data/kumogata-template.gemspec
CHANGED
|
@@ -18,9 +18,10 @@ Gem::Specification.new do |spec|
|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
19
|
spec.require_paths = ['lib']
|
|
20
20
|
|
|
21
|
-
spec.add_dependency 'aws-sdk', '~> 2
|
|
22
|
-
spec.add_dependency '
|
|
23
|
-
spec.
|
|
24
|
-
spec.add_development_dependency '
|
|
25
|
-
spec.add_development_dependency '
|
|
21
|
+
spec.add_dependency 'aws-sdk', '~> 2'
|
|
22
|
+
spec.add_dependency 'kumogata2-plugin-ruby', '0.1.3'
|
|
23
|
+
spec.add_dependency 'kumogata2-plugin-yaml', '0.0.1'
|
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.13'
|
|
25
|
+
spec.add_development_dependency 'rake', '~> 12.0'
|
|
26
|
+
spec.add_development_dependency 'minitest', '~> 5.10'
|
|
26
27
|
end
|
data/lib/kumogata/template.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
require 'kumogata/template/alb'
|
|
2
2
|
require 'kumogata/template/autoscaling'
|
|
3
3
|
require 'kumogata/template/certificate'
|
|
4
|
+
require 'kumogata/template/cloudfront'
|
|
4
5
|
require 'kumogata/template/cloudwatch'
|
|
5
6
|
require 'kumogata/template/codedeploy'
|
|
6
7
|
require 'kumogata/template/const'
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Helper - CloudFront
|
|
3
|
+
#
|
|
4
|
+
require 'kumogata/template/helper'
|
|
5
|
+
|
|
6
|
+
def _cloudfront_distribution_config(args)
|
|
7
|
+
aliases = args[:aliases] || []
|
|
8
|
+
cache =
|
|
9
|
+
if args.key? :cache
|
|
10
|
+
_cloudfront_cache_behavior(args[:cache])
|
|
11
|
+
else
|
|
12
|
+
""
|
|
13
|
+
end
|
|
14
|
+
comment = args[:comment] || ""
|
|
15
|
+
custom_errors =
|
|
16
|
+
if args.key? :custom_errors
|
|
17
|
+
_cloudfront_custom_errors(args[:custom_errors])
|
|
18
|
+
else
|
|
19
|
+
[]
|
|
20
|
+
end
|
|
21
|
+
default_cache =
|
|
22
|
+
if args.key? :default_cache
|
|
23
|
+
_cloudfront_cache_behavior(args[:default_cache], true)
|
|
24
|
+
else
|
|
25
|
+
""
|
|
26
|
+
end
|
|
27
|
+
default_root = args[:default_root] || "index.html"
|
|
28
|
+
enabled = _bool("enabled", args, true)
|
|
29
|
+
http = _valid_values(args[:http], %w( http1.1 http2 ), "http2")
|
|
30
|
+
logging =
|
|
31
|
+
if args.key? :logging
|
|
32
|
+
_cloudfront_logging(args[:logging])
|
|
33
|
+
else
|
|
34
|
+
""
|
|
35
|
+
end
|
|
36
|
+
origins = _cloudfront_origins(args[:origins])
|
|
37
|
+
price = args[:price] || ""
|
|
38
|
+
restrictions = args[:restrictions] || ""
|
|
39
|
+
viewer_cert =
|
|
40
|
+
if args.key? :viewer_cert
|
|
41
|
+
_cloudfront_viewer_cert(args[:viewer_cert])
|
|
42
|
+
else
|
|
43
|
+
""
|
|
44
|
+
end
|
|
45
|
+
web_acl = args[:web_acl] || ""
|
|
46
|
+
|
|
47
|
+
_{
|
|
48
|
+
Aliases aliases unless aliases.empty?
|
|
49
|
+
CacheBehaviors cache unless comment.empty?
|
|
50
|
+
Comment comment unless comment.empty?
|
|
51
|
+
CustomErrorResponses custom_errors unless custom_errors.empty?
|
|
52
|
+
DefaultCacheBehavior default_cache unless default_cache.empty?
|
|
53
|
+
DefaultRootObject default_root unless default_root.empty?
|
|
54
|
+
Enabled enabled
|
|
55
|
+
HttpVersion http unless http.empty?
|
|
56
|
+
Logging logging unless logging.empty?
|
|
57
|
+
Origins origins
|
|
58
|
+
PriceClass price unless price.empty?
|
|
59
|
+
Restrictions restrictions unless restrictions.empty?
|
|
60
|
+
ViewerCertificate viewer_cert unless viewer_cert.empty?
|
|
61
|
+
WebACLId web_acl unless web_acl.empty?
|
|
62
|
+
}
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def _cloudfront_cache_behavior(args, default = false)
|
|
66
|
+
allowed_methods =
|
|
67
|
+
if args.key? :allowed_methods
|
|
68
|
+
case args[:allowed_methods]
|
|
69
|
+
when "with options"
|
|
70
|
+
%w( GET HEAD OPTIONS )
|
|
71
|
+
when "all"
|
|
72
|
+
%w( DELETE GET HEAD OPTIONS PATCH POST PUT )
|
|
73
|
+
else
|
|
74
|
+
%w( HEAD GET )
|
|
75
|
+
end
|
|
76
|
+
else
|
|
77
|
+
""
|
|
78
|
+
end
|
|
79
|
+
cached_methods =
|
|
80
|
+
if args.key? :cached_methods
|
|
81
|
+
case args[:cached_methods]
|
|
82
|
+
when "with options"
|
|
83
|
+
%w( GET HEAD OPTIONS )
|
|
84
|
+
else
|
|
85
|
+
%w( HEAD GET )
|
|
86
|
+
end
|
|
87
|
+
else
|
|
88
|
+
""
|
|
89
|
+
end
|
|
90
|
+
compress =
|
|
91
|
+
if args.key? :compress
|
|
92
|
+
_bool("compress", args, false)
|
|
93
|
+
else
|
|
94
|
+
""
|
|
95
|
+
end
|
|
96
|
+
default_ttl = args[:default_ttl] || nil
|
|
97
|
+
forwarded_values =
|
|
98
|
+
if args.key? :forwarded
|
|
99
|
+
_cloudfront_forwarded_values(args[:forwarded])
|
|
100
|
+
else
|
|
101
|
+
""
|
|
102
|
+
end
|
|
103
|
+
max_ttl = args[:max_ttl] || ""
|
|
104
|
+
min_ttl = args[:min_ttl] || ""
|
|
105
|
+
path = args[:path]
|
|
106
|
+
smooth =
|
|
107
|
+
if args.key? :smooth
|
|
108
|
+
_bool(args[:smooth])
|
|
109
|
+
else
|
|
110
|
+
""
|
|
111
|
+
end
|
|
112
|
+
target = args[:target]
|
|
113
|
+
trusted = args[:trusted] || ""
|
|
114
|
+
viewer = _valid_values(args[:viewer], %w( allow-all redirect-to-https https-only ), "redirect-to-https")
|
|
115
|
+
|
|
116
|
+
_{
|
|
117
|
+
AllowedMethods allowed_methods unless allowed_methods.empty?
|
|
118
|
+
CachedMethods cached_methods unless cached_methods.empty?
|
|
119
|
+
Compress compress unless compress.empty?
|
|
120
|
+
DefaultTTL default_ttl unless default_ttl.nil?
|
|
121
|
+
ForwardedValues forwarded_values
|
|
122
|
+
MaxTTL max_ttl unless max_ttl.empty?
|
|
123
|
+
MinTTL min_ttl unless min_ttl.empty?
|
|
124
|
+
PathPattern path if default == false
|
|
125
|
+
SmoothStreaming smooth unless smooth.empty?
|
|
126
|
+
TargetOriginId target
|
|
127
|
+
TrustedSigners trusted unless trusted.empty?
|
|
128
|
+
ViewerProtocolPolicy viewer
|
|
129
|
+
}
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def _cloudfront_forwared_cookies(args)
|
|
133
|
+
forward = args[:forward] || ""
|
|
134
|
+
white_lists = args[:white_lists] || ""
|
|
135
|
+
|
|
136
|
+
_{
|
|
137
|
+
Forward forward
|
|
138
|
+
WhitelistedNames white_lists
|
|
139
|
+
}
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
def _cloudfront_forwarded_values(args)
|
|
143
|
+
cookies =
|
|
144
|
+
if args.key? :cookies
|
|
145
|
+
_cloudfront_forwared_cookies(args[:cookies])
|
|
146
|
+
else
|
|
147
|
+
""
|
|
148
|
+
end
|
|
149
|
+
headers = args[:headers] || []
|
|
150
|
+
query_string = _bool("query_string", args, false)
|
|
151
|
+
query_string_keys = args[:query_string_keys] || []
|
|
152
|
+
|
|
153
|
+
_{
|
|
154
|
+
Cookies cookies unless cookies.empty?
|
|
155
|
+
Headers headers unless headers.empty?
|
|
156
|
+
QueryString query_string
|
|
157
|
+
QueryStringCacheKeys query_string_keys unless query_string_keys.empty?
|
|
158
|
+
}
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def _cloudfront_custom_error(args)
|
|
162
|
+
error_min_ttl = args[:error_min_ttl] || ""
|
|
163
|
+
error_code = args[:error_code] || 404
|
|
164
|
+
response_code =
|
|
165
|
+
if args.key? :response_code
|
|
166
|
+
args[:response_code] || 404
|
|
167
|
+
else
|
|
168
|
+
error_code
|
|
169
|
+
end
|
|
170
|
+
response_page =
|
|
171
|
+
unless response_code.nil?
|
|
172
|
+
args[:response_page] || "/#{response_code}.html"
|
|
173
|
+
else
|
|
174
|
+
""
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
_{
|
|
178
|
+
ErrorCachingMinTTL error_min_ttl unless error_min_ttl.empty?
|
|
179
|
+
ErrorCode error_code
|
|
180
|
+
ResponseCode response_code unless response_code.nil?
|
|
181
|
+
ResponsePagePath response_page unless response_page.empty?
|
|
182
|
+
}
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
def _cloudfront_custom_errors(args)
|
|
186
|
+
errors = args || []
|
|
187
|
+
|
|
188
|
+
array = []
|
|
189
|
+
errors.each do |error|
|
|
190
|
+
array << _cloudfront_custom_error(error)
|
|
191
|
+
end
|
|
192
|
+
array
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
def _cloudfront_logging(args)
|
|
196
|
+
bucket = _ref_attr_string("bucket", "DomainName", args, "bucket")
|
|
197
|
+
include_cookies =
|
|
198
|
+
if args.key? :include_cookies
|
|
199
|
+
_bool("include_cookies", args, false)
|
|
200
|
+
else
|
|
201
|
+
""
|
|
202
|
+
end
|
|
203
|
+
prefix = args[:prefix] || ""
|
|
204
|
+
|
|
205
|
+
_{
|
|
206
|
+
Bucket bucket
|
|
207
|
+
IncludeCookies include_cookies unless include_cookies.empty?
|
|
208
|
+
Prefix prefix unless prefix.empty?
|
|
209
|
+
}
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
def _cloudfront_origin(args)
|
|
213
|
+
custom =
|
|
214
|
+
if args.key? :custom
|
|
215
|
+
_cloudfront_custom_origin(args[:custom])
|
|
216
|
+
else
|
|
217
|
+
nil
|
|
218
|
+
end
|
|
219
|
+
domain = _ref_attr_string("domain", "DomainName", args, "bucket")
|
|
220
|
+
id = args[:id]
|
|
221
|
+
headers =
|
|
222
|
+
if args.key? :headers
|
|
223
|
+
_cloudfront_origin_headers(args[:headers])
|
|
224
|
+
else
|
|
225
|
+
""
|
|
226
|
+
end
|
|
227
|
+
path = args[:origin_path] || ""
|
|
228
|
+
s3 =
|
|
229
|
+
if args.key? :s3
|
|
230
|
+
_cloudfront_s3_origin(args[:s3])
|
|
231
|
+
else
|
|
232
|
+
nil
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
_{
|
|
236
|
+
CustomOriginConfig custom if s3.nil?
|
|
237
|
+
DomainName domain
|
|
238
|
+
Id id
|
|
239
|
+
OriginCustomHeaders headers unless headers.empty?
|
|
240
|
+
OriginPath path unless path.empty?
|
|
241
|
+
S3OriginConfig s3 if custom.nil?
|
|
242
|
+
}
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
def _cloudfront_origins(args)
|
|
246
|
+
origins = args || []
|
|
247
|
+
|
|
248
|
+
array = []
|
|
249
|
+
origins.each do |origin|
|
|
250
|
+
array << _cloudfront_origin(origin)
|
|
251
|
+
end
|
|
252
|
+
array
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
def _cloudfront_custom_origin(args)
|
|
256
|
+
http_port = args[:http_port] || ""
|
|
257
|
+
https_port = args[:https_port] || ""
|
|
258
|
+
origin_protocol = args[:origin_protocol] || ""
|
|
259
|
+
origin_ssl_protocols = args[:origin_ssl_protocols] || []
|
|
260
|
+
|
|
261
|
+
_{
|
|
262
|
+
HTTPPort http_port unless http_port.empty?
|
|
263
|
+
HTTPSPort https_port unless https_port.empty?
|
|
264
|
+
OriginProtocolPolicy origin_protocol unless origin_protocol.empty?
|
|
265
|
+
OriginSSLProtocols origin_ssl_protocols unless origin_ssl_protocols.empty?
|
|
266
|
+
}
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
def _cloudfront_s3_origin(args)
|
|
270
|
+
origin = args[:origin] || ""
|
|
271
|
+
|
|
272
|
+
_{
|
|
273
|
+
OriginAccessIdentity origin unless origin.empty?
|
|
274
|
+
}
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
def _cloudfront_origin_headers(args)
|
|
278
|
+
name = args[:name]
|
|
279
|
+
value = args[:value]
|
|
280
|
+
|
|
281
|
+
_{
|
|
282
|
+
HeaderName name
|
|
283
|
+
HeaderValue value
|
|
284
|
+
}
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
def _cloudfront_viewer_cert(args)
|
|
288
|
+
acm = _ref_string("acm", args)
|
|
289
|
+
default =
|
|
290
|
+
if args.key? :default
|
|
291
|
+
_bool("default", args, false)
|
|
292
|
+
else
|
|
293
|
+
""
|
|
294
|
+
end
|
|
295
|
+
iam = args[:iam] || ""
|
|
296
|
+
min_protocol = args[:min_protocol] || ""
|
|
297
|
+
ssl = _valid_values(args[:ssl], %w( vip sni-only ), "sni-only")
|
|
298
|
+
|
|
299
|
+
_{
|
|
300
|
+
AcmCertificateArn acm unless acm.empty?
|
|
301
|
+
CloudFrontDefaultCertificate default_cert unless default.empty?
|
|
302
|
+
IamCertificateId iam unless iam.empty?
|
|
303
|
+
MinimumProtocolVersion min_protocol unless min_protocol.empty?
|
|
304
|
+
SslSupportMethod ssl unless acm.empty? and iam.empty?
|
|
305
|
+
}
|
|
306
|
+
end
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
require '
|
|
2
|
-
require '
|
|
1
|
+
require 'kumogata2'
|
|
2
|
+
require 'kumogata2/cli/option_parser'
|
|
3
|
+
require 'kumogata2/logger'
|
|
4
|
+
require 'kumogata2/plugin/ruby'
|
|
3
5
|
|
|
4
|
-
class
|
|
6
|
+
class Kumogata2::Client
|
|
5
7
|
def init(stack_name)
|
|
6
8
|
begin
|
|
7
9
|
base_template = ''
|
|
@@ -21,13 +23,29 @@ class Kumogata::Client
|
|
|
21
23
|
template = base_template.gsub('#{NAME}', stack_name)
|
|
22
24
|
f.write(template)
|
|
23
25
|
}
|
|
24
|
-
|
|
26
|
+
Kumogata2::Logger::Helper.log(:info, "Saved template to #{stack_name}.rb".green)
|
|
25
27
|
rescue => e
|
|
26
|
-
|
|
28
|
+
Kumogata2::Logger::Helper.log(:error, "Failed to template #{stack_name} - #{e}".red)
|
|
27
29
|
end
|
|
28
30
|
nil
|
|
29
31
|
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
class Kumogata2::Plugin::Ruby
|
|
35
|
+
def parse(str)
|
|
36
|
+
str = <<EOS
|
|
37
|
+
template do
|
|
38
|
+
#{str}
|
|
39
|
+
end
|
|
40
|
+
EOS
|
|
41
|
+
context = Kumogata2::Plugin::Ruby::Context.new(@options)
|
|
42
|
+
context.instance_eval(str, @options.path_or_url)
|
|
43
|
+
@post = context.instance_variable_get(:@_post)
|
|
44
|
+
context.instance_variable_get(:@_template)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
30
47
|
|
|
48
|
+
class Kumogata2::Plugin::Ruby::Context
|
|
31
49
|
def define_template_func(scope, path_or_url)
|
|
32
50
|
functions = ''
|
|
33
51
|
Dir.glob(File.join(get_template_path, '*.rb')).all? do |file|
|
|
@@ -100,40 +118,6 @@ class Kumogata::Client
|
|
|
100
118
|
template_path
|
|
101
119
|
end
|
|
102
120
|
|
|
103
|
-
def evaluate_template(template, path_or_url)
|
|
104
|
-
key_converter = proc do |key|
|
|
105
|
-
key = key.to_s
|
|
106
|
-
unless @options.skip_replace_underscore?
|
|
107
|
-
key.gsub!('_', ':')
|
|
108
|
-
key.gsub!('__', '::')
|
|
109
|
-
end
|
|
110
|
-
key
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
value_converter = proc do |v|
|
|
114
|
-
case v
|
|
115
|
-
when Hash, Array
|
|
116
|
-
v
|
|
117
|
-
else
|
|
118
|
-
v.to_s
|
|
119
|
-
end
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
template = Dslh.eval(template.read, {
|
|
123
|
-
:key_conv => key_converter,
|
|
124
|
-
:value_conv => value_converter,
|
|
125
|
-
:scope_hook => proc {|scope|
|
|
126
|
-
define_template_func(scope, path_or_url)
|
|
127
|
-
},
|
|
128
|
-
:filename => path_or_url,
|
|
129
|
-
})
|
|
130
|
-
|
|
131
|
-
@outputs_filter.fetch!(template)
|
|
132
|
-
@post_processing.fetch!(template)
|
|
133
|
-
|
|
134
|
-
return template
|
|
135
|
-
end
|
|
136
|
-
|
|
137
121
|
def devaluate_template(template)
|
|
138
122
|
exclude_key = proc do |k|
|
|
139
123
|
k = k.to_s.gsub('::', '__')
|
|
@@ -152,7 +136,6 @@ class Kumogata::Client
|
|
|
152
136
|
end
|
|
153
137
|
end
|
|
154
138
|
else
|
|
155
|
-
k.gsub(':', '_')
|
|
156
139
|
k.gsub('::', '__')
|
|
157
140
|
end
|
|
158
141
|
end
|
|
@@ -165,6 +148,22 @@ class Kumogata::Client
|
|
|
165
148
|
end
|
|
166
149
|
end
|
|
167
150
|
|
|
168
|
-
|
|
151
|
+
dslh_opts = {
|
|
152
|
+
key_conv: key_conv,
|
|
153
|
+
value_conv: value_conv,
|
|
154
|
+
exclude_key: exclude_key,
|
|
155
|
+
initial_depth: 1,
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if ENV['EXPORT_RUBY_USE_BRACES'] == '1'
|
|
159
|
+
dslh_opts[:use_braces_instead_of_do_end] = true
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
if ENV['EXPORT_RUBY_OLD_FORMAT'] == '1'
|
|
163
|
+
dslh_opts[:dump_old_hash_array_format] = true
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
dsl = Dslh.deval(template, dslh_opts)
|
|
167
|
+
dsl.strip
|
|
169
168
|
end
|
|
170
169
|
end
|
data/lib/kumogata/template/s3.rb
CHANGED
|
@@ -7,21 +7,21 @@ def _s3_to_access(value)
|
|
|
7
7
|
return "Private" if value.nil?
|
|
8
8
|
|
|
9
9
|
case value
|
|
10
|
-
when "auth"
|
|
10
|
+
when "auth read"
|
|
11
11
|
"AuthenticatedRead"
|
|
12
|
-
when "
|
|
12
|
+
when "aws exec read"
|
|
13
13
|
"AwsExecRead"
|
|
14
|
-
when "owner"
|
|
14
|
+
when "owner read"
|
|
15
15
|
"BucketOwnerRead"
|
|
16
|
-
when "
|
|
16
|
+
when "owner full"
|
|
17
17
|
"BucketOwnerFullControl"
|
|
18
|
-
when "
|
|
18
|
+
when "log delivery write"
|
|
19
19
|
"LogDeliveryWrite"
|
|
20
20
|
when "private"
|
|
21
21
|
"Private"
|
|
22
|
-
when "
|
|
22
|
+
when "public read"
|
|
23
23
|
"PublicRead"
|
|
24
|
-
when "
|
|
24
|
+
when "public read write"
|
|
25
25
|
"PublicReadWrite"
|
|
26
26
|
else
|
|
27
27
|
value
|
|
@@ -1 +1 @@
|
|
|
1
|
-
KUMOGATA_TEMPLATE_VERSION = '0.0.
|
|
1
|
+
KUMOGATA_TEMPLATE_VERSION = '0.0.15'
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#
|
|
2
|
+
# CloudFront web distribution
|
|
3
|
+
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudfront-distribution.html
|
|
4
|
+
#
|
|
5
|
+
require 'kumogata/template/helper'
|
|
6
|
+
require 'kumogata/template/cloudfront'
|
|
7
|
+
|
|
8
|
+
name = _resource_name(args[:name], "distribution")
|
|
9
|
+
config = _cloudfront_distribution_config(args)
|
|
10
|
+
|
|
11
|
+
_(name) do
|
|
12
|
+
Type "AWS::CloudFront::Distribution"
|
|
13
|
+
Properties do
|
|
14
|
+
DistributionConfig config
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -24,7 +24,7 @@ threshold = args[:threshold] || 60
|
|
|
24
24
|
unit = _valid_values(args[:unit], %w(Seconds Microseconds Milliseconds Bytes Kilobytes Megabytes Gigabytes Terabytes Bits Kilobits Megabits Gigabits Terabits Percent Count Bytes/Second Kilobytes/Second Megabytes/Second Gigabytes/Second Terabytes/Second Bits/Second Kilobits/Second Megabits/Second Gigabits/Second Terabits/Second Count/Second None), "")
|
|
25
25
|
|
|
26
26
|
_(name) do
|
|
27
|
-
Type AWS::CloudWatch::Alarm
|
|
27
|
+
Type "AWS::CloudWatch::Alarm"
|
|
28
28
|
Properties do
|
|
29
29
|
ActionsEnabled enabled
|
|
30
30
|
AlarmActions actions
|
data/template/ec2-volume.rb
CHANGED
data/template/s3-bucket.rb
CHANGED
|
@@ -6,8 +6,12 @@ require 'kumogata/template/helper'
|
|
|
6
6
|
require 'kumogata/template/s3'
|
|
7
7
|
|
|
8
8
|
name = _resource_name(args[:name], "bucket")
|
|
9
|
-
access =
|
|
10
|
-
|
|
9
|
+
access =
|
|
10
|
+
if args.key? :website
|
|
11
|
+
"PublicRead"
|
|
12
|
+
else
|
|
13
|
+
_s3_to_access(args[:access])
|
|
14
|
+
end
|
|
11
15
|
bucket = _ref_name("bucket", args)
|
|
12
16
|
cors = _s3_cors(args)
|
|
13
17
|
lifecycle = _s3_lifecycle(args)
|
data/test/abstract_unit.rb
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
require 'minitest/autorun'
|
|
2
|
-
require '
|
|
3
|
-
require '
|
|
2
|
+
require 'kumogata2'
|
|
3
|
+
require 'kumogata2/cli/option_parser'
|
|
4
|
+
require 'kumogata2/plugin/ruby'
|
|
4
5
|
require 'json'
|
|
5
6
|
require 'tempfile'
|
|
6
7
|
|
|
7
8
|
# for only test
|
|
8
9
|
ENV['TZ'] = 'Asia/Tokyo'
|
|
9
10
|
|
|
10
|
-
class
|
|
11
|
+
class Kumogata2::Client
|
|
12
|
+
include Kumogata2::Logger::Helper
|
|
13
|
+
|
|
14
|
+
def initialize(options)
|
|
15
|
+
@options = options.kind_of?(Hashie::Mash) ? options : Hashie::Mash.new(options)
|
|
16
|
+
@plugin_by_ext = {}
|
|
17
|
+
## Do not initialize AWS client
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
class Kumogata2::Plugin::Ruby::Context
|
|
11
22
|
def define_template_func(scope, path_or_url)
|
|
12
23
|
functions = ""
|
|
13
24
|
Dir.glob("template/*.rb").all? do |file|
|
|
@@ -73,6 +84,11 @@ def tempfile(content, template_ext = nil)
|
|
|
73
84
|
basename = "#{File.basename __FILE__}.#{$$}"
|
|
74
85
|
basename = [basename, template_ext] if template_ext
|
|
75
86
|
|
|
87
|
+
content = <<EOS
|
|
88
|
+
template do
|
|
89
|
+
#{content}
|
|
90
|
+
end
|
|
91
|
+
EOS
|
|
76
92
|
Tempfile.open(basename) do |f|
|
|
77
93
|
f << content
|
|
78
94
|
f.flush
|
|
@@ -84,14 +100,16 @@ end
|
|
|
84
100
|
def run_client(template)
|
|
85
101
|
$stdout = open('/dev/null', 'w') unless ENV['DEBUG']
|
|
86
102
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
103
|
+
Kumogata2::Plugin.load_plugins
|
|
104
|
+
|
|
105
|
+
options = Kumogata2::CLI::OptionParser::DEFAULT_OPTIONS
|
|
106
|
+
options[:output_format] = 'json'
|
|
107
|
+
options[:result_log] = '/dev/null'
|
|
108
|
+
options[:command_result_log] = '/dev/null'
|
|
91
109
|
template_ext = '.rb'
|
|
92
110
|
|
|
93
111
|
template = tempfile(template, template_ext) do |f|
|
|
94
|
-
|
|
112
|
+
Kumogata2::Client.new(options).send(:open_template, f.path)
|
|
95
113
|
end
|
|
96
114
|
end
|
|
97
115
|
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
require 'abstract_unit'
|
|
2
|
+
require 'kumogata/template/cloudfront'
|
|
3
|
+
|
|
4
|
+
class CloudFrontTest < Minitest::Test
|
|
5
|
+
def test_cloudfront_distribution_config
|
|
6
|
+
template = <<-EOS
|
|
7
|
+
Test _cloudfront_distribution_config({ origins: [{ domain: "test", id: "test", s3: {} }] })
|
|
8
|
+
EOS
|
|
9
|
+
act_template = run_client_as_json(template)
|
|
10
|
+
exp_template = <<-EOS
|
|
11
|
+
{
|
|
12
|
+
"Test": {
|
|
13
|
+
"DefaultRootObject": "index.html",
|
|
14
|
+
"Enabled": "true",
|
|
15
|
+
"HttpVersion": "http2",
|
|
16
|
+
"Origins": [
|
|
17
|
+
{
|
|
18
|
+
"DomainName": "test",
|
|
19
|
+
"Id": "test",
|
|
20
|
+
"S3OriginConfig": {
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
EOS
|
|
27
|
+
assert_equal exp_template.chomp, act_template
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def test_cloudfront_cache_behavior
|
|
31
|
+
template = <<-EOS
|
|
32
|
+
Test _cloudfront_cache_behavior({ forwarded: {}, path: "test", target: "test", viewer: "test" })
|
|
33
|
+
EOS
|
|
34
|
+
act_template = run_client_as_json(template)
|
|
35
|
+
exp_template = <<-EOS
|
|
36
|
+
{
|
|
37
|
+
"Test": {
|
|
38
|
+
"ForwardedValues": {
|
|
39
|
+
"QueryString": "false"
|
|
40
|
+
},
|
|
41
|
+
"PathPattern": "test",
|
|
42
|
+
"TargetOriginId": "test",
|
|
43
|
+
"ViewerProtocolPolicy": "redirect-to-https"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
EOS
|
|
47
|
+
assert_equal exp_template.chomp, act_template
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def test_cloudfront_forwared_cookies
|
|
51
|
+
template = <<-EOS
|
|
52
|
+
Test _cloudfront_forwared_cookies({ forward: "test", white_lists: "test" })
|
|
53
|
+
EOS
|
|
54
|
+
act_template = run_client_as_json(template)
|
|
55
|
+
exp_template = <<-EOS
|
|
56
|
+
{
|
|
57
|
+
"Test": {
|
|
58
|
+
"Forward": "test",
|
|
59
|
+
"WhitelistedNames": "test"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
EOS
|
|
63
|
+
assert_equal exp_template.chomp, act_template
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def test_cloudfront_forwarded_values
|
|
67
|
+
template = <<-EOS
|
|
68
|
+
Test _cloudfront_forwarded_values({})
|
|
69
|
+
EOS
|
|
70
|
+
act_template = run_client_as_json(template)
|
|
71
|
+
exp_template = <<-EOS
|
|
72
|
+
{
|
|
73
|
+
"Test": {
|
|
74
|
+
"QueryString": "false"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
EOS
|
|
78
|
+
assert_equal exp_template.chomp, act_template
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def test_cloudfront_custom_error
|
|
82
|
+
template = <<-EOS
|
|
83
|
+
Test _cloudfront_custom_error({})
|
|
84
|
+
EOS
|
|
85
|
+
act_template = run_client_as_json(template)
|
|
86
|
+
exp_template = <<-EOS
|
|
87
|
+
{
|
|
88
|
+
"Test": {
|
|
89
|
+
"ErrorCode": "404",
|
|
90
|
+
"ResponseCode": "404",
|
|
91
|
+
"ResponsePagePath": "/404.html"
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
EOS
|
|
95
|
+
assert_equal exp_template.chomp, act_template
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def test_cloudfront_custom_errors
|
|
99
|
+
template = <<-EOS
|
|
100
|
+
Test _cloudfront_custom_errors([ {} ])
|
|
101
|
+
EOS
|
|
102
|
+
act_template = run_client_as_json(template)
|
|
103
|
+
exp_template = <<-EOS
|
|
104
|
+
{
|
|
105
|
+
"Test": [
|
|
106
|
+
{
|
|
107
|
+
"ErrorCode": "404",
|
|
108
|
+
"ResponseCode": "404",
|
|
109
|
+
"ResponsePagePath": "/404.html"
|
|
110
|
+
}
|
|
111
|
+
]
|
|
112
|
+
}
|
|
113
|
+
EOS
|
|
114
|
+
assert_equal exp_template.chomp, act_template
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def test_cloudfront_logging
|
|
118
|
+
template = <<-EOS
|
|
119
|
+
Test _cloudfront_logging({ bucket: "test" })
|
|
120
|
+
EOS
|
|
121
|
+
act_template = run_client_as_json(template)
|
|
122
|
+
exp_template = <<-EOS
|
|
123
|
+
{
|
|
124
|
+
"Test": {
|
|
125
|
+
"Bucket": "test"
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
EOS
|
|
129
|
+
assert_equal exp_template.chomp, act_template
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def test_cloudfront_origin
|
|
133
|
+
template = <<-EOS
|
|
134
|
+
Test _cloudfront_origin({ domain: "test", id: "test", s3: {} })
|
|
135
|
+
EOS
|
|
136
|
+
act_template = run_client_as_json(template)
|
|
137
|
+
exp_template = <<-EOS
|
|
138
|
+
{
|
|
139
|
+
"Test": {
|
|
140
|
+
"DomainName": "test",
|
|
141
|
+
"Id": "test",
|
|
142
|
+
"S3OriginConfig": {
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
EOS
|
|
147
|
+
assert_equal exp_template.chomp, act_template
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def test_cloudfront_origins
|
|
151
|
+
template = <<-EOS
|
|
152
|
+
Test _cloudfront_origins([ { domain: "test1", id: "test1", s3: {} },
|
|
153
|
+
{ domain: "test2", id: "test2", s3: {} } ])
|
|
154
|
+
EOS
|
|
155
|
+
act_template = run_client_as_json(template)
|
|
156
|
+
exp_template = <<-EOS
|
|
157
|
+
{
|
|
158
|
+
"Test": [
|
|
159
|
+
{
|
|
160
|
+
"DomainName": "test1",
|
|
161
|
+
"Id": "test1",
|
|
162
|
+
"S3OriginConfig": {
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"DomainName": "test2",
|
|
167
|
+
"Id": "test2",
|
|
168
|
+
"S3OriginConfig": {
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
]
|
|
172
|
+
}
|
|
173
|
+
EOS
|
|
174
|
+
assert_equal exp_template.chomp, act_template
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def test_cloudfront_custom_origin
|
|
178
|
+
template = <<-EOS
|
|
179
|
+
Test _cloudfront_custom_origin({})
|
|
180
|
+
EOS
|
|
181
|
+
act_template = run_client_as_json(template)
|
|
182
|
+
exp_template = <<-EOS
|
|
183
|
+
{
|
|
184
|
+
"Test": {
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
EOS
|
|
188
|
+
assert_equal exp_template.chomp, act_template
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
def test_cloudfront_s3_origin
|
|
192
|
+
template = <<-EOS
|
|
193
|
+
Test _cloudfront_s3_origin({})
|
|
194
|
+
EOS
|
|
195
|
+
act_template = run_client_as_json(template)
|
|
196
|
+
exp_template = <<-EOS
|
|
197
|
+
{
|
|
198
|
+
"Test": {
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
EOS
|
|
202
|
+
assert_equal exp_template.chomp, act_template
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
def test_cloudfront_custom_origin
|
|
206
|
+
template = <<-EOS
|
|
207
|
+
Test _cloudfront_custom_origin({})
|
|
208
|
+
EOS
|
|
209
|
+
act_template = run_client_as_json(template)
|
|
210
|
+
exp_template = <<-EOS
|
|
211
|
+
{
|
|
212
|
+
"Test": {
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
EOS
|
|
216
|
+
assert_equal exp_template.chomp, act_template
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
def test_cloudfront_s3_origin
|
|
220
|
+
template = <<-EOS
|
|
221
|
+
Test _cloudfront_s3_origin({})
|
|
222
|
+
EOS
|
|
223
|
+
act_template = run_client_as_json(template)
|
|
224
|
+
exp_template = <<-EOS
|
|
225
|
+
{
|
|
226
|
+
"Test": {
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
EOS
|
|
230
|
+
assert_equal exp_template.chomp, act_template
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
def test_cloudfront_origin_headers
|
|
235
|
+
template = <<-EOS
|
|
236
|
+
Test _cloudfront_origin_headers({ name: "test", value: "test" })
|
|
237
|
+
EOS
|
|
238
|
+
act_template = run_client_as_json(template)
|
|
239
|
+
exp_template = <<-EOS
|
|
240
|
+
{
|
|
241
|
+
"Test": {
|
|
242
|
+
"HeaderName": "test",
|
|
243
|
+
"HeaderValue": "test"
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
EOS
|
|
247
|
+
assert_equal exp_template.chomp, act_template
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
def test_cloudfront_viewer_cert
|
|
251
|
+
template = <<-EOS
|
|
252
|
+
Test _cloudfront_viewer_cert({ acm: "test" })
|
|
253
|
+
EOS
|
|
254
|
+
act_template = run_client_as_json(template)
|
|
255
|
+
exp_template = <<-EOS
|
|
256
|
+
{
|
|
257
|
+
"Test": {
|
|
258
|
+
"AcmCertificateArn": "test",
|
|
259
|
+
"SslSupportMethod": "sni-only"
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
EOS
|
|
263
|
+
assert_equal exp_template.chomp, act_template
|
|
264
|
+
end
|
|
265
|
+
end
|
data/test/helper_test.rb
CHANGED
|
@@ -36,8 +36,8 @@ class HelperTest < Minitest::Test
|
|
|
36
36
|
assert_equal _valid_numbers(1, 0, 1, 2), 1
|
|
37
37
|
assert_equal _valid_numbers(2, 1, 2, 4), 2
|
|
38
38
|
assert_equal _valid_numbers(2, 0, 1, 2), 2
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
assert_nil _valid_numbers(3, 0, 1)
|
|
40
|
+
assert_nil _valid_numbers(nil, 0, 1)
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
def test_ref_string
|
data/test/s3_test.rb
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require 'abstract_unit'
|
|
2
|
+
|
|
3
|
+
class CloudfrontDistributionTest < Minitest::Test
|
|
4
|
+
def test_normal
|
|
5
|
+
template = <<-EOS
|
|
6
|
+
_cloudfront_distribution "test", { origins: [{ domain: "test", id: "test", s3: {} }] }
|
|
7
|
+
EOS
|
|
8
|
+
act_template = run_client_as_json(template)
|
|
9
|
+
exp_template = <<-EOS
|
|
10
|
+
{
|
|
11
|
+
"TestDistribution": {
|
|
12
|
+
"Type": "AWS::CloudFront::Distribution",
|
|
13
|
+
"Properties": {
|
|
14
|
+
"DistributionConfig": {
|
|
15
|
+
"DefaultRootObject": "index.html",
|
|
16
|
+
"Enabled": "true",
|
|
17
|
+
"HttpVersion": "http2",
|
|
18
|
+
"Origins": [
|
|
19
|
+
{
|
|
20
|
+
"DomainName": "test",
|
|
21
|
+
"Id": "test",
|
|
22
|
+
"S3OriginConfig": {
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
EOS
|
|
31
|
+
assert_equal exp_template.chomp, act_template
|
|
32
|
+
end
|
|
33
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kumogata-template
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.15
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Naoya Nakazawa
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-01-
|
|
11
|
+
date: 2017-01-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: aws-sdk
|
|
@@ -16,70 +16,84 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '2
|
|
19
|
+
version: '2'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '2
|
|
26
|
+
version: '2'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name:
|
|
28
|
+
name: kumogata2-plugin-ruby
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
31
|
- - '='
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: 0.
|
|
33
|
+
version: 0.1.3
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - '='
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: 0.
|
|
40
|
+
version: 0.1.3
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: kumogata2-plugin-yaml
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - '='
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: 0.0.1
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - '='
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: 0.0.1
|
|
41
55
|
- !ruby/object:Gem::Dependency
|
|
42
56
|
name: bundler
|
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
|
44
58
|
requirements:
|
|
45
59
|
- - "~>"
|
|
46
60
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '1.
|
|
61
|
+
version: '1.13'
|
|
48
62
|
type: :development
|
|
49
63
|
prerelease: false
|
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
65
|
requirements:
|
|
52
66
|
- - "~>"
|
|
53
67
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '1.
|
|
68
|
+
version: '1.13'
|
|
55
69
|
- !ruby/object:Gem::Dependency
|
|
56
70
|
name: rake
|
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
|
58
72
|
requirements:
|
|
59
73
|
- - "~>"
|
|
60
74
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '
|
|
75
|
+
version: '12.0'
|
|
62
76
|
type: :development
|
|
63
77
|
prerelease: false
|
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
79
|
requirements:
|
|
66
80
|
- - "~>"
|
|
67
81
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '
|
|
82
|
+
version: '12.0'
|
|
69
83
|
- !ruby/object:Gem::Dependency
|
|
70
84
|
name: minitest
|
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
|
72
86
|
requirements:
|
|
73
87
|
- - "~>"
|
|
74
88
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: '5.
|
|
89
|
+
version: '5.10'
|
|
76
90
|
type: :development
|
|
77
91
|
prerelease: false
|
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
93
|
requirements:
|
|
80
94
|
- - "~>"
|
|
81
95
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: '5.
|
|
96
|
+
version: '5.10'
|
|
83
97
|
description: Template for Kumogata. Kumogata is a tool for AWS CloudFormation. It
|
|
84
98
|
can define a template in Ruby DSL.
|
|
85
99
|
email:
|
|
@@ -101,6 +115,7 @@ files:
|
|
|
101
115
|
- lib/kumogata/template/alb.rb
|
|
102
116
|
- lib/kumogata/template/autoscaling.rb
|
|
103
117
|
- lib/kumogata/template/certificate.rb
|
|
118
|
+
- lib/kumogata/template/cloudfront.rb
|
|
104
119
|
- lib/kumogata/template/cloudwatch.rb
|
|
105
120
|
- lib/kumogata/template/codedeploy.rb
|
|
106
121
|
- lib/kumogata/template/const.rb
|
|
@@ -112,8 +127,8 @@ files:
|
|
|
112
127
|
- lib/kumogata/template/elb.rb
|
|
113
128
|
- lib/kumogata/template/emr.rb
|
|
114
129
|
- lib/kumogata/template/events.rb
|
|
115
|
-
- lib/kumogata/template/ext/argument_parser.rb
|
|
116
130
|
- lib/kumogata/template/ext/kumogata.rb
|
|
131
|
+
- lib/kumogata/template/ext/option_parser.rb
|
|
117
132
|
- lib/kumogata/template/helper.rb
|
|
118
133
|
- lib/kumogata/template/iam.rb
|
|
119
134
|
- lib/kumogata/template/lambda.rb
|
|
@@ -131,6 +146,7 @@ files:
|
|
|
131
146
|
- template/autoscaling-scaling-policy.rb
|
|
132
147
|
- template/autoscaling-scheduled-action.rb
|
|
133
148
|
- template/certificate.rb
|
|
149
|
+
- template/cloudfront-distribution.rb
|
|
134
150
|
- template/cloudtrail.rb
|
|
135
151
|
- template/cloudwatch-alarm.rb
|
|
136
152
|
- template/codedeploy-application.rb
|
|
@@ -231,6 +247,7 @@ files:
|
|
|
231
247
|
- test/abstract_unit.rb
|
|
232
248
|
- test/alb_test.rb
|
|
233
249
|
- test/autoscaling_test.rb
|
|
250
|
+
- test/cloudfront_test.rb
|
|
234
251
|
- test/codedeploy_test.rb
|
|
235
252
|
- test/data/lambda_function.py
|
|
236
253
|
- test/datapipeline_test.rb
|
|
@@ -256,6 +273,7 @@ files:
|
|
|
256
273
|
- test/template/autoscaling-scaling-policy_test.rb
|
|
257
274
|
- test/template/autoscaling-scheduled-action_test.rb
|
|
258
275
|
- test/template/certificate_test.rb
|
|
276
|
+
- test/template/cloudfront-distribution_test.rb
|
|
259
277
|
- test/template/cloudtrail_test.rb
|
|
260
278
|
- test/template/cloudwatch-alarm_test.rb
|
|
261
279
|
- test/template/codedeploy-application_test.rb
|
|
@@ -381,6 +399,7 @@ test_files:
|
|
|
381
399
|
- test/abstract_unit.rb
|
|
382
400
|
- test/alb_test.rb
|
|
383
401
|
- test/autoscaling_test.rb
|
|
402
|
+
- test/cloudfront_test.rb
|
|
384
403
|
- test/codedeploy_test.rb
|
|
385
404
|
- test/data/lambda_function.py
|
|
386
405
|
- test/datapipeline_test.rb
|
|
@@ -406,6 +425,7 @@ test_files:
|
|
|
406
425
|
- test/template/autoscaling-scaling-policy_test.rb
|
|
407
426
|
- test/template/autoscaling-scheduled-action_test.rb
|
|
408
427
|
- test/template/certificate_test.rb
|
|
428
|
+
- test/template/cloudfront-distribution_test.rb
|
|
409
429
|
- test/template/cloudtrail_test.rb
|
|
410
430
|
- test/template/cloudwatch-alarm_test.rb
|
|
411
431
|
- test/template/codedeploy-application_test.rb
|