cfndk 0.1.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.circleci/config.yml +8 -5
- data/.gitignore +1 -0
- data/.rspec +2 -0
- data/Gemfile +0 -11
- data/Gemfile.lock +1069 -587
- data/README.md +124 -10
- data/cfndk.gemspec +7 -2
- data/docker/Dockerfile +8 -0
- data/docker/build.sh +3 -0
- data/docker/cfndk.sh +14 -0
- data/lib/cfndk/change_set_command.rb +14 -8
- data/lib/cfndk/command.rb +14 -6
- data/lib/cfndk/credential_provider_chain.rb +12 -42
- data/lib/cfndk/credential_resolvable.rb +10 -0
- data/lib/cfndk/diff.rb +38 -0
- data/lib/cfndk/global_config.rb +33 -2
- data/lib/cfndk/key_pair.rb +33 -1
- data/lib/cfndk/key_pair_command.rb +10 -3
- data/lib/cfndk/key_pairs.rb +12 -0
- data/lib/cfndk/stack.rb +67 -60
- data/lib/cfndk/stack_command.rb +26 -8
- data/lib/cfndk/stacks.rb +16 -0
- data/lib/cfndk/template_packager.rb +210 -0
- data/lib/cfndk/uuid.rb +10 -0
- data/lib/cfndk/version.rb +1 -1
- data/lib/cfndk.rb +12 -1
- data/spec/cfndk_spec.rb +1 -1
- data/spec/cfndk_stack_create_spec.rb +365 -5
- data/spec/cfndk_stack_destroy_spec.rb +64 -0
- data/spec/cfndk_stack_update_spec.rb +86 -0
- data/spec/fixtures/big_vpc.yaml +533 -0
- data/spec/fixtures/lambda_function/index.js +4 -0
- data/spec/fixtures/lambda_function/lambda_function.json +4 -0
- data/spec/fixtures/lambda_function/lambda_function.yaml +28 -0
- data/spec/fixtures/nested_stack.json +35 -0
- data/spec/fixtures/nested_stack.yaml +20 -0
- data/spec/fixtures/serverless_function/index.js +4 -0
- data/spec/fixtures/serverless_function/serverless_function.json +4 -0
- data/spec/fixtures/serverless_function/serverless_function.yaml +21 -0
- data/spec/fixtures/stack.json +8 -0
- data/spec/fixtures/stack.template.json +39 -0
- data/spec/fixtures/stack.yaml +22 -0
- data/spec/fixtures/vpc.template.json +40 -0
- data/vagrant/Vagrantfile +89 -0
- metadata +117 -13
@@ -97,7 +97,7 @@ RSpec.describe 'CFnDK', type: :aruba do
|
|
97
97
|
end
|
98
98
|
after(:each) { run_command('cfndk destroy -f') }
|
99
99
|
end
|
100
|
-
context 'with a
|
100
|
+
context 'with a stack and enabled is true', enabled: true do
|
101
101
|
yaml = <<-"YAML"
|
102
102
|
global:
|
103
103
|
stacks:
|
@@ -105,11 +105,59 @@ RSpec.describe 'CFnDK', type: :aruba do
|
|
105
105
|
template_file: vpc.yaml
|
106
106
|
parameter_input: vpc.json
|
107
107
|
timeout_in_minutes: 2
|
108
|
+
enabled: true
|
108
109
|
YAML
|
109
110
|
before(:each) { write_file(file, yaml) }
|
110
111
|
before(:each) { copy('%/vpc.yaml', 'vpc.yaml') }
|
111
112
|
before(:each) { copy('%/vpc.json', 'vpc.json') }
|
112
|
-
before(:each) {
|
113
|
+
before(:each) { run_command('cfndk stack create') }
|
114
|
+
it do
|
115
|
+
aggregate_failures do
|
116
|
+
expect(last_command_started).to be_successfully_executed
|
117
|
+
expect(last_command_started).to have_output(/INFO validate stack: Test$/)
|
118
|
+
expect(last_command_started).to have_output(/INFO creating stack: Test$/)
|
119
|
+
expect(last_command_started).to have_output(/INFO created stack: Test$/)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
after(:each) { run_command('cfndk destroy -f') }
|
123
|
+
end
|
124
|
+
context 'with a stack and enabled is false', enabled: true do
|
125
|
+
yaml = <<-"YAML"
|
126
|
+
global:
|
127
|
+
stacks:
|
128
|
+
Test:
|
129
|
+
template_file: vpc.yaml
|
130
|
+
parameter_input: vpc.json
|
131
|
+
timeout_in_minutes: 2
|
132
|
+
enabled: false
|
133
|
+
YAML
|
134
|
+
before(:each) { write_file(file, yaml) }
|
135
|
+
before(:each) { copy('%/vpc.yaml', 'vpc.yaml') }
|
136
|
+
before(:each) { copy('%/vpc.json', 'vpc.json') }
|
137
|
+
before(:each) { run_command('cfndk stack create') }
|
138
|
+
it do
|
139
|
+
aggregate_failures do
|
140
|
+
expect(last_command_started).to be_successfully_executed
|
141
|
+
expect(last_command_started).to have_output(/INFO create.../)
|
142
|
+
expect(last_command_started).not_to have_output(/INFO validate stack: Test$/)
|
143
|
+
expect(last_command_started).not_to have_output(/INFO creating stack: Test$/)
|
144
|
+
expect(last_command_started).not_to have_output(/INFO created stack: Test$/)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
after(:each) { run_command('cfndk destroy -f') }
|
148
|
+
end
|
149
|
+
context 'with a 51200byte template stack' do
|
150
|
+
yaml = <<-"YAML"
|
151
|
+
global:
|
152
|
+
stacks:
|
153
|
+
Test:
|
154
|
+
template_file: vpc.yaml
|
155
|
+
parameter_input: vpc.json
|
156
|
+
timeout_in_minutes: 2
|
157
|
+
YAML
|
158
|
+
before(:each) { write_file(file, yaml) }
|
159
|
+
before(:each) { copy('%/big_vpc.yaml', 'vpc.yaml') }
|
160
|
+
before(:each) { copy('%/vpc.json', 'vpc.json') }
|
113
161
|
before(:each) { run_command('cfndk stack create') }
|
114
162
|
it 'displays created stack log' do
|
115
163
|
aggregate_failures do
|
@@ -122,7 +170,7 @@ RSpec.describe 'CFnDK', type: :aruba do
|
|
122
170
|
end
|
123
171
|
after(:each) { run_command('cfndk destroy -f') }
|
124
172
|
end
|
125
|
-
context 'with a 51201byte template stack', big: true do
|
173
|
+
context 'with a 51201byte template stack', big: true, bigbig: true do
|
126
174
|
yaml = <<-"YAML"
|
127
175
|
global:
|
128
176
|
stacks:
|
@@ -132,9 +180,9 @@ RSpec.describe 'CFnDK', type: :aruba do
|
|
132
180
|
timeout_in_minutes: 2
|
133
181
|
YAML
|
134
182
|
before(:each) { write_file(file, yaml) }
|
135
|
-
before(:each) { copy('%/
|
183
|
+
before(:each) { copy('%/big_vpc.yaml', 'vpc.yaml') }
|
136
184
|
before(:each) { copy('%/vpc.json', 'vpc.json') }
|
137
|
-
before(:each) { append_to_file('vpc.yaml', '
|
185
|
+
before(:each) { append_to_file('vpc.yaml', '1') }
|
138
186
|
before(:each) { run_command('cfndk stack create') }
|
139
187
|
it 'displays created stack log' do
|
140
188
|
aggregate_failures do
|
@@ -147,6 +195,183 @@ RSpec.describe 'CFnDK', type: :aruba do
|
|
147
195
|
end
|
148
196
|
after(:each) { run_command('cfndk destroy -f') }
|
149
197
|
end
|
198
|
+
context 'with stack and nested stack', nested: true do
|
199
|
+
yaml = <<-"YAML"
|
200
|
+
global:
|
201
|
+
stacks:
|
202
|
+
Test:
|
203
|
+
template_file: vpc.yaml
|
204
|
+
parameter_input: vpc.json
|
205
|
+
timeout_in_minutes: 2
|
206
|
+
package: true
|
207
|
+
YAML
|
208
|
+
before(:each) { write_file(file, yaml) }
|
209
|
+
before(:each) { copy('%/stack.yaml', 'vpc.yaml') }
|
210
|
+
before(:each) { copy('%/stack.json', 'vpc.json') }
|
211
|
+
before(:each) { copy('%/nested_stack.yaml', 'nested_stack.yaml') }
|
212
|
+
before(:each) { run_command('cfndk stack create') }
|
213
|
+
it 'displays created stack log' do
|
214
|
+
aggregate_failures do
|
215
|
+
expect(last_command_started).to be_successfully_executed
|
216
|
+
expect(last_command_started).to have_output(/INFO validate stack: Test$/)
|
217
|
+
expect(last_command_started).to have_output(/INFO creating stack: Test$/)
|
218
|
+
expect(last_command_started).to have_output(/INFO created stack: Test$/)
|
219
|
+
expect(last_command_started).to have_output(%r{INFO Put S3 object: https://s3.amazonaws.com/[0-9]+-ap-northeast-1-cfndk-templates/.+/nested_stack.yaml})
|
220
|
+
end
|
221
|
+
end
|
222
|
+
after(:each) { run_command('cfndk destroy -f') }
|
223
|
+
end
|
224
|
+
context 'with stack with directory and nested stack', directory_nested: true do
|
225
|
+
yaml = <<-"YAML"
|
226
|
+
global:
|
227
|
+
stacks:
|
228
|
+
Test:
|
229
|
+
template_file: vpc/vpc.yaml
|
230
|
+
parameter_input: vpc/vpc.json
|
231
|
+
timeout_in_minutes: 2
|
232
|
+
package: true
|
233
|
+
YAML
|
234
|
+
before(:each) { write_file(file, yaml) }
|
235
|
+
before(:each) { copy('%/stack.yaml', 'vpc/vpc.yaml') }
|
236
|
+
before(:each) { copy('%/stack.json', 'vpc/vpc.json') }
|
237
|
+
before(:each) { copy('%/nested_stack.yaml', 'vpc/nested_stack.yaml') }
|
238
|
+
before(:each) { run_command('cfndk stack create') }
|
239
|
+
it 'displays created stack log' do
|
240
|
+
aggregate_failures do
|
241
|
+
expect(last_command_started).to be_successfully_executed
|
242
|
+
expect(last_command_started).to have_output(/INFO validate stack: Test$/)
|
243
|
+
expect(last_command_started).to have_output(/INFO creating stack: Test$/)
|
244
|
+
expect(last_command_started).to have_output(/INFO created stack: Test$/)
|
245
|
+
expect(last_command_started).to have_output(%r{INFO Put S3 object: https://s3.amazonaws.com/[0-9]+-ap-northeast-1-cfndk-templates/.+/nested_stack.yaml})
|
246
|
+
end
|
247
|
+
end
|
248
|
+
after(:each) { run_command('cfndk destroy -f') }
|
249
|
+
end
|
250
|
+
context 'with a 51201byte template stack and nested stack', nested: true, big: true, nested_big: true do
|
251
|
+
yaml = <<-"YAML"
|
252
|
+
global:
|
253
|
+
stacks:
|
254
|
+
Test:
|
255
|
+
template_file: vpc.yaml
|
256
|
+
parameter_input: vpc.json
|
257
|
+
timeout_in_minutes: 2
|
258
|
+
package: true
|
259
|
+
YAML
|
260
|
+
before(:each) { write_file(file, yaml) }
|
261
|
+
before(:each) { copy('%/stack.yaml', 'vpc.yaml') }
|
262
|
+
before(:each) { copy('%/stack.json', 'vpc.json') }
|
263
|
+
before(:each) { copy('%/nested_stack.yaml', 'nested_stack.yaml') }
|
264
|
+
before(:each) {
|
265
|
+
append_to_file('vpc.yaml', "\nOutputs:\n")
|
266
|
+
for number in 1..40 do
|
267
|
+
stack_append = <<-"YAML"
|
268
|
+
VpcId012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345#{number.to_s}:
|
269
|
+
Description: 01234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678901234567890123
|
270
|
+
Value: !Ref Vpc
|
271
|
+
Export:
|
272
|
+
Name: !Sub ${VpcName}-VpcId012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345#{number.to_s}
|
273
|
+
YAML
|
274
|
+
append_to_file('vpc.yaml', stack_append)
|
275
|
+
# p read('vpc.yaml').join("\n").length
|
276
|
+
end
|
277
|
+
}
|
278
|
+
before(:each) { append_to_file('nested_stack.yaml', "\n" + '#' * (51200 + 1 - 2 - file_size('nested_stack.yaml').to_i)) }
|
279
|
+
before(:each) { run_command('cfndk stack create') }
|
280
|
+
it 'displays created stack log' do
|
281
|
+
aggregate_failures do
|
282
|
+
expect(last_command_started).to be_successfully_executed
|
283
|
+
expect(last_command_started).to have_output(/INFO validate stack: Test$/)
|
284
|
+
expect(last_command_started).to have_output(/INFO creating stack: Test$/)
|
285
|
+
expect(last_command_started).to have_output(/INFO created stack: Test$/)
|
286
|
+
expect(last_command_started).to have_output(%r{INFO Put S3 object: https://s3.amazonaws.com/[0-9]+-ap-northeast-1-cfndk-templates/.+/vpc.yaml})
|
287
|
+
expect(last_command_started).to have_output(%r{INFO Put S3 object: https://s3.amazonaws.com/[0-9]+-ap-northeast-1-cfndk-templates/.+/nested_stack.yaml})
|
288
|
+
end
|
289
|
+
end
|
290
|
+
after(:each) { run_command('cfndk destroy -f') }
|
291
|
+
end
|
292
|
+
context 'with json stack and json nested stack', nested: true, json: true do
|
293
|
+
yaml = <<-"YAML"
|
294
|
+
global:
|
295
|
+
stacks:
|
296
|
+
Test:
|
297
|
+
template_file: vpc.template.json
|
298
|
+
parameter_input: vpc.json
|
299
|
+
timeout_in_minutes: 2
|
300
|
+
package: true
|
301
|
+
YAML
|
302
|
+
before(:each) { write_file(file, yaml) }
|
303
|
+
before(:each) { copy('%/stack.template.json', 'vpc.template.json') }
|
304
|
+
before(:each) { copy('%/stack.json', 'vpc.json') }
|
305
|
+
before(:each) { copy('%/nested_stack.json', 'nested_stack.json') }
|
306
|
+
before(:each) { run_command('cfndk stack create') }
|
307
|
+
it 'displays created stack log' do
|
308
|
+
aggregate_failures do
|
309
|
+
expect(last_command_started).to be_successfully_executed
|
310
|
+
expect(last_command_started).to have_output(/INFO validate stack: Test$/)
|
311
|
+
expect(last_command_started).to have_output(/INFO creating stack: Test$/)
|
312
|
+
expect(last_command_started).to have_output(/INFO created stack: Test$/)
|
313
|
+
expect(last_command_started).to have_output(%r{INFO Put S3 object: https://s3.amazonaws.com/[0-9]+-ap-northeast-1-cfndk-templates/.+/nested_stack.json})
|
314
|
+
end
|
315
|
+
end
|
316
|
+
after(:each) { run_command('cfndk destroy -f') }
|
317
|
+
end
|
318
|
+
context 'with lambda function and zip file', lambda_function: true do
|
319
|
+
yaml = <<-"YAML"
|
320
|
+
global:
|
321
|
+
stacks:
|
322
|
+
Test:
|
323
|
+
template_file: lambda_function.yaml
|
324
|
+
parameter_input: lambda_function.json
|
325
|
+
timeout_in_minutes: 2
|
326
|
+
capabilities:
|
327
|
+
- CAPABILITY_IAM
|
328
|
+
package: true
|
329
|
+
YAML
|
330
|
+
before(:each) { write_file(file, yaml) }
|
331
|
+
before(:each) { copy('%/lambda_function/lambda_function.yaml', 'lambda_function.yaml') }
|
332
|
+
before(:each) { copy('%/lambda_function/lambda_function.json', 'lambda_function.json') }
|
333
|
+
before(:each) { copy('%/lambda_function/index.js', 'lambda_function/index.js') }
|
334
|
+
before(:each) { run_command('cfndk stack create') }
|
335
|
+
it 'displays created stack log' do
|
336
|
+
aggregate_failures do
|
337
|
+
expect(last_command_started).to be_successfully_executed
|
338
|
+
expect(last_command_started).to have_output(/INFO validate stack: Test$/)
|
339
|
+
expect(last_command_started).to have_output(/INFO creating stack: Test$/)
|
340
|
+
expect(last_command_started).to have_output(/INFO created stack: Test$/)
|
341
|
+
expect(last_command_started).to have_output(%r{INFO Put S3 object: https://s3.amazonaws.com/[0-9]+-ap-northeast-1-cfndk-templates/.+/lambda_function.zip})
|
342
|
+
end
|
343
|
+
end
|
344
|
+
after(:each) { run_command('cfndk destroy -f') }
|
345
|
+
end
|
346
|
+
context 'with serverless function and zip file', serverless_function: true do
|
347
|
+
yaml = <<-"YAML"
|
348
|
+
global:
|
349
|
+
stacks:
|
350
|
+
Test:
|
351
|
+
template_file: serverless_function.yaml
|
352
|
+
parameter_input: serverless_function.json
|
353
|
+
timeout_in_minutes: 2
|
354
|
+
capabilities:
|
355
|
+
- CAPABILITY_AUTO_EXPAND
|
356
|
+
- CAPABILITY_IAM
|
357
|
+
package: true
|
358
|
+
YAML
|
359
|
+
before(:each) { write_file(file, yaml) }
|
360
|
+
before(:each) { copy('%/serverless_function/serverless_function.yaml', 'serverless_function.yaml') }
|
361
|
+
before(:each) { copy('%/serverless_function/serverless_function.json', 'serverless_function.json') }
|
362
|
+
before(:each) { copy('%/serverless_function/index.js', 'serverless_function/index.js') }
|
363
|
+
before(:each) { run_command('cfndk stack create') }
|
364
|
+
it 'displays created stack log' do
|
365
|
+
aggregate_failures do
|
366
|
+
expect(last_command_started).to be_successfully_executed
|
367
|
+
expect(last_command_started).to have_output(/INFO validate stack: Test$/)
|
368
|
+
expect(last_command_started).to have_output(/INFO creating stack: Test$/)
|
369
|
+
expect(last_command_started).to have_output(/INFO created stack: Test$/)
|
370
|
+
expect(last_command_started).to have_output(%r{INFO Put S3 object: https://s3.amazonaws.com/[0-9]+-ap-northeast-1-cfndk-templates/.+/serverless_function.zip})
|
371
|
+
end
|
372
|
+
end
|
373
|
+
after(:each) { run_command('cfndk destroy -f') }
|
374
|
+
end
|
150
375
|
context 'with two stacks' do
|
151
376
|
yaml = <<-"YAML"
|
152
377
|
stacks:
|
@@ -180,6 +405,141 @@ RSpec.describe 'CFnDK', type: :aruba do
|
|
180
405
|
end
|
181
406
|
after(:each) { run_command('cfndk destroy -f') }
|
182
407
|
end
|
408
|
+
context 'with stack and command', global_pre_command: true, global_post_command: true, pre_command: true, post_command: true do
|
409
|
+
yaml = <<-"YAML"
|
410
|
+
global:
|
411
|
+
pre_command: echo "global pre command"
|
412
|
+
post_command: echo "global post command"
|
413
|
+
stacks:
|
414
|
+
Test:
|
415
|
+
template_file: vpc.yaml
|
416
|
+
parameter_input: vpc.json
|
417
|
+
timeout_in_minutes: 2
|
418
|
+
pre_command: echo "Test pre command"
|
419
|
+
post_command: echo "Test post command"
|
420
|
+
YAML
|
421
|
+
|
422
|
+
before(:each) { write_file(file, yaml) }
|
423
|
+
before(:each) { copy('%/vpc.yaml', 'vpc.yaml') }
|
424
|
+
before(:each) { copy('%/vpc.json', 'vpc.json') }
|
425
|
+
before(:each) { run_command('cfndk stack create') }
|
426
|
+
it do
|
427
|
+
aggregate_failures do
|
428
|
+
expect(last_command_started).to be_successfully_executed
|
429
|
+
expect(last_command_started).to have_output(/INFO execute global pre command: echo "global pre command"$/)
|
430
|
+
expect(last_command_started).to have_output(/INFO global pre command$/)
|
431
|
+
expect(last_command_started).to have_output(/INFO execute pre command: echo "Test pre command"$/)
|
432
|
+
expect(last_command_started).to have_output(/INFO Test pre command$/)
|
433
|
+
expect(last_command_started).to have_output(/INFO validate stack: Test$/)
|
434
|
+
expect(last_command_started).to have_output(/INFO creating stack: Test$/)
|
435
|
+
expect(last_command_started).to have_output(/INFO created stack: Test$/)
|
436
|
+
expect(last_command_started).to have_output(/INFO execute post command: echo "Test post command"$/)
|
437
|
+
expect(last_command_started).to have_output(/INFO Test post command$/)
|
438
|
+
expect(last_command_started).to have_output(/INFO execute global post command: echo "global post command"$/)
|
439
|
+
expect(last_command_started).to have_output(/INFO global post command$/)
|
440
|
+
end
|
441
|
+
end
|
442
|
+
after(:each) { run_command('cfndk destroy -f') }
|
443
|
+
end
|
444
|
+
|
445
|
+
context 'with stack and error global pre command', global_pre_command: true do
|
446
|
+
yaml = <<-"YAML"
|
447
|
+
global:
|
448
|
+
pre_command: exit 1
|
449
|
+
stacks:
|
450
|
+
Test:
|
451
|
+
template_file: vpc.yaml
|
452
|
+
parameter_input: vpc.json
|
453
|
+
timeout_in_minutes: 2
|
454
|
+
YAML
|
455
|
+
|
456
|
+
before(:each) { write_file(file, yaml) }
|
457
|
+
before(:each) { copy('%/vpc.yaml', 'vpc.yaml') }
|
458
|
+
before(:each) { copy('%/vpc.json', 'vpc.json') }
|
459
|
+
before(:each) { run_command('cfndk stack create') }
|
460
|
+
it do
|
461
|
+
aggregate_failures do
|
462
|
+
expect(last_command_started).not_to be_successfully_executed
|
463
|
+
expect(last_command_started).to have_output(/INFO execute global pre command: exit 1$/)
|
464
|
+
expect(last_command_started).to have_output(/ERROR RuntimeError: global pre command is error. status: 1 command: exit 1$/)
|
465
|
+
end
|
466
|
+
end
|
467
|
+
after(:each) { run_command('cfndk destroy -f') }
|
468
|
+
end
|
469
|
+
|
470
|
+
context 'with stack and error global post command', global_post_command: true do
|
471
|
+
yaml = <<-"YAML"
|
472
|
+
global:
|
473
|
+
post_command: exit 1
|
474
|
+
stacks:
|
475
|
+
Test:
|
476
|
+
template_file: vpc.yaml
|
477
|
+
parameter_input: vpc.json
|
478
|
+
timeout_in_minutes: 2
|
479
|
+
YAML
|
480
|
+
|
481
|
+
before(:each) { write_file(file, yaml) }
|
482
|
+
before(:each) { copy('%/vpc.yaml', 'vpc.yaml') }
|
483
|
+
before(:each) { copy('%/vpc.json', 'vpc.json') }
|
484
|
+
before(:each) { run_command('cfndk stack create') }
|
485
|
+
it do
|
486
|
+
aggregate_failures do
|
487
|
+
expect(last_command_started).not_to be_successfully_executed
|
488
|
+
expect(last_command_started).to have_output(/INFO execute global post command: exit 1$/)
|
489
|
+
expect(last_command_started).to have_output(/ERROR RuntimeError: global post command is error. status: 1 command: exit 1$/)
|
490
|
+
end
|
491
|
+
end
|
492
|
+
after(:each) { run_command('cfndk destroy -f') }
|
493
|
+
end
|
494
|
+
|
495
|
+
context 'with stack and error pre command', pre_command: true do
|
496
|
+
yaml = <<-"YAML"
|
497
|
+
stacks:
|
498
|
+
Test:
|
499
|
+
template_file: vpc.yaml
|
500
|
+
parameter_input: vpc.json
|
501
|
+
timeout_in_minutes: 2
|
502
|
+
pre_command: exit 1
|
503
|
+
YAML
|
504
|
+
|
505
|
+
before(:each) { write_file(file, yaml) }
|
506
|
+
before(:each) { copy('%/vpc.yaml', 'vpc.yaml') }
|
507
|
+
before(:each) { copy('%/vpc.json', 'vpc.json') }
|
508
|
+
before(:each) { run_command('cfndk stack create') }
|
509
|
+
it do
|
510
|
+
aggregate_failures do
|
511
|
+
expect(last_command_started).not_to be_successfully_executed
|
512
|
+
expect(last_command_started).to have_output(/INFO execute pre command: exit 1$/)
|
513
|
+
expect(last_command_started).to have_output(/ERROR RuntimeError: pre command is error. status: 1 command: exit 1$/)
|
514
|
+
end
|
515
|
+
end
|
516
|
+
after(:each) { run_command('cfndk destroy -f') }
|
517
|
+
end
|
518
|
+
|
519
|
+
context 'with stack and error post command', post_command: true do
|
520
|
+
yaml = <<-"YAML"
|
521
|
+
stacks:
|
522
|
+
Test:
|
523
|
+
template_file: vpc.yaml
|
524
|
+
parameter_input: vpc.json
|
525
|
+
timeout_in_minutes: 2
|
526
|
+
post_command: exit 1
|
527
|
+
YAML
|
528
|
+
|
529
|
+
before(:each) { write_file(file, yaml) }
|
530
|
+
before(:each) { copy('%/vpc.yaml', 'vpc.yaml') }
|
531
|
+
before(:each) { copy('%/vpc.json', 'vpc.json') }
|
532
|
+
before(:each) { run_command('cfndk stack create') }
|
533
|
+
it do
|
534
|
+
aggregate_failures do
|
535
|
+
expect(last_command_started).not_to be_successfully_executed
|
536
|
+
expect(last_command_started).to have_output(/INFO execute post command: exit 1$/)
|
537
|
+
expect(last_command_started).to have_output(/ERROR RuntimeError: post command is error. status: 1 command: exit 1$/)
|
538
|
+
end
|
539
|
+
end
|
540
|
+
after(:each) { run_command('cfndk destroy -f') }
|
541
|
+
end
|
542
|
+
|
183
543
|
context 'when invalid dependency', dependency: true do
|
184
544
|
yaml = <<-"YAML"
|
185
545
|
stacks:
|
@@ -153,6 +153,70 @@ RSpec.describe 'CFnDK', type: :aruba do
|
|
153
153
|
end
|
154
154
|
after(:each) { run_command('cfndk destroy -f') }
|
155
155
|
end
|
156
|
+
context 'when keyparis and stacks exist and enabled is true', enabled: true do
|
157
|
+
yaml = <<-"YAML"
|
158
|
+
keypairs:
|
159
|
+
Test1:
|
160
|
+
stacks:
|
161
|
+
Test:
|
162
|
+
template_file: vpc.yaml
|
163
|
+
parameter_input: vpc.json
|
164
|
+
parameters:
|
165
|
+
VpcName: sample<%= append_uuid%>
|
166
|
+
timeout_in_minutes: 2
|
167
|
+
enabled: true
|
168
|
+
YAML
|
169
|
+
before(:each) { write_file(file, yaml) }
|
170
|
+
before(:each) { copy('%/vpc.yaml', 'vpc.yaml') }
|
171
|
+
before(:each) { copy('%/vpc.json', 'vpc.json') }
|
172
|
+
before(:each) { run_command('cfndk create') }
|
173
|
+
before(:each) { stop_all_commands }
|
174
|
+
before(:each) { run_command('cfndk stack destroy') }
|
175
|
+
before(:each) { type('yes') }
|
176
|
+
before(:each) { stop_all_commands }
|
177
|
+
it 'displays confirm message and delete message' do
|
178
|
+
aggregate_failures do
|
179
|
+
expect(last_command_started).to be_successfully_executed
|
180
|
+
expect(last_command_started).to have_output(/INFO destroy../)
|
181
|
+
expect(last_command_started).to have_output(%r{Are you sure you want to destroy\? \(y/n\)})
|
182
|
+
expect(last_command_started).not_to have_output(/INFO deleted keypair: Test1$/)
|
183
|
+
expect(last_command_started).to have_output(/INFO deleted stack: Test$/)
|
184
|
+
end
|
185
|
+
end
|
186
|
+
after(:each) { run_command('cfndk destroy -f') }
|
187
|
+
end
|
188
|
+
context 'when keyparis and stacks exist and enabled is false', enabled: true do
|
189
|
+
yaml = <<-"YAML"
|
190
|
+
keypairs:
|
191
|
+
Test1:
|
192
|
+
stacks:
|
193
|
+
Test:
|
194
|
+
template_file: vpc.yaml
|
195
|
+
parameter_input: vpc.json
|
196
|
+
parameters:
|
197
|
+
VpcName: sample<%= append_uuid%>
|
198
|
+
timeout_in_minutes: 2
|
199
|
+
enabled: false
|
200
|
+
YAML
|
201
|
+
before(:each) { write_file(file, yaml) }
|
202
|
+
before(:each) { copy('%/vpc.yaml', 'vpc.yaml') }
|
203
|
+
before(:each) { copy('%/vpc.json', 'vpc.json') }
|
204
|
+
before(:each) { run_command('cfndk create') }
|
205
|
+
before(:each) { stop_all_commands }
|
206
|
+
before(:each) { run_command('cfndk stack destroy') }
|
207
|
+
before(:each) { type('yes') }
|
208
|
+
before(:each) { stop_all_commands }
|
209
|
+
it 'displays confirm message and delete message' do
|
210
|
+
aggregate_failures do
|
211
|
+
expect(last_command_started).to be_successfully_executed
|
212
|
+
expect(last_command_started).to have_output(/INFO destroy../)
|
213
|
+
expect(last_command_started).to have_output(%r{Are you sure you want to destroy\? \(y/n\)})
|
214
|
+
expect(last_command_started).not_to have_output(/INFO deleted keypair: Test1$/)
|
215
|
+
expect(last_command_started).not_to have_output(/INFO deleted stack: Test$/)
|
216
|
+
end
|
217
|
+
end
|
218
|
+
after(:each) { run_command('cfndk destroy -f') }
|
219
|
+
end
|
156
220
|
end
|
157
221
|
end
|
158
222
|
end
|
@@ -164,6 +164,92 @@ RSpec.describe 'CFnDK', type: :aruba do
|
|
164
164
|
end
|
165
165
|
after(:each) { run_command('cfndk destroy -f') }
|
166
166
|
end
|
167
|
+
context 'with a stack and enabled is true', test: true do
|
168
|
+
yaml = <<-"YAML"
|
169
|
+
stacks:
|
170
|
+
Test:
|
171
|
+
template_file: vpc.yaml
|
172
|
+
parameter_input: vpc.json
|
173
|
+
timeout_in_minutes: 2
|
174
|
+
enabled: true
|
175
|
+
YAML
|
176
|
+
before(:each) { write_file(file, yaml) }
|
177
|
+
before(:each) { copy('%/vpc.yaml', 'vpc.yaml') }
|
178
|
+
before(:each) { copy('%/vpc.json', 'vpc.json') }
|
179
|
+
context 'when stack already exist' do
|
180
|
+
context 'when same yaml' do
|
181
|
+
before(:each) { run_command_and_stop('cfndk stack create') }
|
182
|
+
before(:each) { run_command('cfndk stack update') }
|
183
|
+
it 'displays No update warn' do
|
184
|
+
aggregate_failures do
|
185
|
+
expect(last_command_started).to have_exit_status(0)
|
186
|
+
expect(last_command_started).to have_output(/INFO validate stack: Test$/)
|
187
|
+
expect(last_command_started).to have_output(/INFO updating stack: Test$/)
|
188
|
+
expect(last_command_started).to have_output(/WARN No updates are to be performed\.: Test$/)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
context 'when different yaml' do
|
193
|
+
before(:each) { run_command_and_stop('cfndk stack create') }
|
194
|
+
before(:each) { copy('%/vpc_different.yaml', 'vpc.yaml') }
|
195
|
+
before(:each) { run_command('cfndk stack update') }
|
196
|
+
before(:each) { append_to_file('vpc.yaml', ' ' * (51200 + 1 - file_size('vpc.yaml').to_i)) }
|
197
|
+
it 'displays update log' do
|
198
|
+
aggregate_failures do
|
199
|
+
expect(last_command_started).to be_successfully_executed
|
200
|
+
expect(last_command_started).to have_output(/INFO validate stack: Test$/)
|
201
|
+
expect(last_command_started).to have_output(/INFO updating stack: Test$/)
|
202
|
+
expect(last_command_started).to have_output(/INFO updated stack: Test$/)
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
after(:each) { run_command('cfndk destroy -f') }
|
208
|
+
end
|
209
|
+
context 'with a stack and enabled is false', test: true do
|
210
|
+
yaml = <<-"YAML"
|
211
|
+
stacks:
|
212
|
+
Test:
|
213
|
+
template_file: vpc.yaml
|
214
|
+
parameter_input: vpc.json
|
215
|
+
timeout_in_minutes: 2
|
216
|
+
enabled: false
|
217
|
+
YAML
|
218
|
+
before(:each) { write_file(file, yaml) }
|
219
|
+
before(:each) { copy('%/vpc.yaml', 'vpc.yaml') }
|
220
|
+
before(:each) { copy('%/vpc.json', 'vpc.json') }
|
221
|
+
context 'when stack already exist' do
|
222
|
+
context 'when same yaml' do
|
223
|
+
before(:each) { run_command_and_stop('cfndk stack create') }
|
224
|
+
before(:each) { run_command('cfndk stack update') }
|
225
|
+
it 'displays No update warn' do
|
226
|
+
aggregate_failures do
|
227
|
+
expect(last_command_started).to have_exit_status(0)
|
228
|
+
expect(last_command_started).to have_output(/INFO update...$/)
|
229
|
+
expect(last_command_started).not_to have_output(/INFO validate stack: Test$/)
|
230
|
+
expect(last_command_started).not_to have_output(/INFO updating stack: Test$/)
|
231
|
+
expect(last_command_started).not_to have_output(/WARN No updates are to be performed\.: Test$/)
|
232
|
+
end
|
233
|
+
end
|
234
|
+
end
|
235
|
+
context 'when different yaml' do
|
236
|
+
before(:each) { run_command_and_stop('cfndk stack create') }
|
237
|
+
before(:each) { copy('%/vpc_different.yaml', 'vpc.yaml') }
|
238
|
+
before(:each) { run_command('cfndk stack update') }
|
239
|
+
before(:each) { append_to_file('vpc.yaml', ' ' * (51200 + 1 - file_size('vpc.yaml').to_i)) }
|
240
|
+
it 'displays update log' do
|
241
|
+
aggregate_failures do
|
242
|
+
expect(last_command_started).to be_successfully_executed
|
243
|
+
expect(last_command_started).to have_output(/INFO update...$/)
|
244
|
+
expect(last_command_started).not_to have_output(/INFO validate stack: Test$/)
|
245
|
+
expect(last_command_started).not_to have_output(/INFO updating stack: Test$/)
|
246
|
+
expect(last_command_started).not_to have_output(/INFO updated stack: Test$/)
|
247
|
+
end
|
248
|
+
end
|
249
|
+
end
|
250
|
+
end
|
251
|
+
after(:each) { run_command('cfndk destroy -f') }
|
252
|
+
end
|
167
253
|
context 'with two stacks' do
|
168
254
|
yaml = <<-"YAML"
|
169
255
|
stacks:
|