cfndk 0.1.0 → 0.1.1

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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +23 -14
  3. data/.gitignore +0 -1
  4. data/.rspec_parallel +6 -0
  5. data/Gemfile +1 -0
  6. data/Gemfile.lock +811 -0
  7. data/README.md +122 -10
  8. data/cfndk.gemspec +1 -0
  9. data/lib/cfndk/change_set_command.rb +97 -0
  10. data/lib/cfndk/command.rb +15 -181
  11. data/lib/cfndk/config_file_loadable.rb +13 -0
  12. data/lib/cfndk/global_config.rb +15 -0
  13. data/lib/cfndk/key_pair.rb +7 -4
  14. data/lib/cfndk/key_pair_command.rb +53 -0
  15. data/lib/cfndk/key_pairs.rb +2 -1
  16. data/lib/cfndk/logger.rb +1 -1
  17. data/lib/cfndk/stack.rb +382 -103
  18. data/lib/cfndk/stack_command.rb +110 -0
  19. data/lib/cfndk/stacks.rb +40 -14
  20. data/lib/cfndk/subcommand_help_returnable.rb +16 -0
  21. data/lib/cfndk/version.rb +1 -1
  22. data/lib/cfndk.rb +6 -0
  23. data/skel/cfndk.yml +4 -0
  24. data/spec/cfndk_change_set_create_spec.rb +436 -0
  25. data/spec/cfndk_change_set_destroy_spec.rb +160 -0
  26. data/spec/cfndk_change_set_execute_spec.rb +179 -0
  27. data/spec/cfndk_change_set_report_spec.rb +107 -0
  28. data/spec/cfndk_change_set_spec.rb +37 -0
  29. data/spec/cfndk_create_spec.rb +56 -141
  30. data/spec/cfndk_destroy_spec.rb +4 -2
  31. data/spec/cfndk_keypiar_spec.rb +11 -9
  32. data/spec/cfndk_report_spec.rb +3 -1
  33. data/spec/cfndk_spec.rb +5 -3
  34. data/spec/cfndk_stack_create_spec.rb +454 -0
  35. data/spec/cfndk_stack_destroy_spec.rb +161 -0
  36. data/spec/cfndk_stack_report_spec.rb +181 -0
  37. data/spec/cfndk_stack_spec.rb +6 -1146
  38. data/spec/cfndk_stack_update_spec.rb +467 -0
  39. data/spec/spec_helper.rb +4 -1
  40. data/spec/support/aruba.rb +1 -0
  41. metadata +42 -2
@@ -3,6 +3,8 @@ require 'spec_helper'
3
3
  RSpec.describe 'CFnDK', type: :aruba do
4
4
  before(:each) { set_environment_variable('AWS_REGION', ENV['AWS_REGION']) }
5
5
  before(:each) { set_environment_variable('AWS_PROFILE', ENV['AWS_PROFILE']) }
6
+ before(:each) { set_environment_variable('AWS_ACCESS_KEY_ID', ENV["AWS_ACCESS_KEY_ID#{ENV['TEST_ENV_NUMBER']}"]) }
7
+ before(:each) { set_environment_variable('AWS_SECRET_ACCESS_KEY', ENV["AWS_SECRET_ACCESS_KEY#{ENV['TEST_ENV_NUMBER']}"]) }
6
8
  describe 'bin/cfndk' do
7
9
  before(:each) { setup_aruba }
8
10
  let(:file) { 'cfndk.yml' }
@@ -31,992 +33,13 @@ RSpec.describe 'CFnDK', type: :aruba do
31
33
  end
32
34
  end
33
35
 
34
- describe 'create', create: true do
35
- context 'without cfndk.yml' do
36
- before(:each) { run_command('cfndk stack create') }
37
- it 'displays file does not exist error and status code = 1' do
38
- aggregate_failures do
39
- expect(last_command_started).to have_exit_status(1)
40
- expect(last_command_started).to have_output(/ERROR File does not exist./)
41
- end
42
- end
43
- end
44
-
45
- context 'with cfndk2.yml' do
46
- yaml = <<-"YAML"
47
- keypairs:
48
- YAML
49
- before(:each) { write_file(file2, yaml) }
50
- context 'when -c cfndk2.yml and empty stacks' do
51
- before(:each) { run_command("cfndk stack create -c=#{file2}") }
52
- it 'displays empty stack log' do
53
- aggregate_failures do
54
- expect(last_command_started).to be_successfully_executed
55
- expect(last_command_started).to have_output(/INFO create.../)
56
- end
57
- end
58
- end
59
-
60
- context 'when --config-path cfndk2.yml and empty stacks' do
61
- before(:each) { run_command("cfndk stack create --config-path=#{file2}") }
62
- it 'displays empty stack log' do
63
- aggregate_failures do
64
- expect(last_command_started).to be_successfully_executed
65
- expect(last_command_started).to have_output(/INFO create.../)
66
- end
67
- end
68
- end
69
- end
70
-
71
- context 'with cfndk.yml' do
72
- context 'when cfndk.yml is empty' do
73
- before(:each) { touch(file) }
74
- before(:each) { run_command('cfndk stack create') }
75
- it 'displays File is empty error and status code = 1' do
76
- aggregate_failures do
77
- expect(last_command_started).to have_exit_status(1)
78
- expect(last_command_started).to have_output(/ERROR File is empty./)
79
- end
80
- end
81
- end
82
-
83
- context 'with stacks:' do
84
- context 'without stack' do
85
- before(:each) { write_file(file, 'stacks:') }
86
- before(:each) { run_command('cfndk stack create') }
87
- it do
88
- aggregate_failures do
89
- expect(last_command_started).to be_successfully_executed
90
- expect(last_command_started).to have_output(/INFO create.../)
91
- end
92
- end
93
- end
94
-
95
- context 'with a stack' do
96
- yaml = <<-"YAML"
97
- stacks:
98
- Test:
99
- template_file: vpc.yaml
100
- parameter_input: vpc.json
101
- timeout_in_minutes: 2
102
- YAML
103
- before(:each) { write_file(file, yaml) }
104
- before(:each) { copy('%/vpc.yaml', 'vpc.yaml') }
105
- before(:each) { copy('%/vpc.json', 'vpc.json') }
106
- before(:each) { run_command('cfndk stack create') }
107
- it do
108
- aggregate_failures do
109
- expect(last_command_started).to be_successfully_executed
110
- expect(last_command_started).to have_output(/INFO validate stack: Test$/)
111
- expect(last_command_started).to have_output(/INFO creating stack: Test$/)
112
- expect(last_command_started).to have_output(/INFO created stack: Test$/)
113
- end
114
- end
115
- after(:each) { run_command('cfndk destroy -f') }
116
- end
117
- context 'with two stacks' do
118
- yaml = <<-"YAML"
119
- stacks:
120
- Test:
121
- template_file: vpc.yaml
122
- parameter_input: vpc.json
123
- timeout_in_minutes: 2
124
- Test2:
125
- template_file: sg.yaml
126
- parameter_input: sg.json
127
- depends:
128
- - Test
129
- YAML
130
-
131
- before(:each) { write_file(file, yaml) }
132
- before(:each) { copy('%/vpc.yaml', 'vpc.yaml') }
133
- before(:each) { copy('%/vpc.json', 'vpc.json') }
134
- before(:each) { copy('%/sg.yaml', 'sg.yaml') }
135
- before(:each) { copy('%/sg.json', 'sg.json') }
136
- before(:each) { run_command('cfndk stack create') }
137
- it do
138
- aggregate_failures do
139
- expect(last_command_started).to be_successfully_executed
140
- expect(last_command_started).to have_output(/INFO validate stack: Test$/)
141
- expect(last_command_started).to have_output(/INFO creating stack: Test$/)
142
- expect(last_command_started).to have_output(/INFO created stack: Test$/)
143
- expect(last_command_started).to have_output(/INFO validate stack: Test2$/)
144
- expect(last_command_started).to have_output(/INFO creating stack: Test2$/)
145
- expect(last_command_started).to have_output(/INFO created stack: Test2$/)
146
- end
147
- end
148
- after(:each) { run_command('cfndk destroy -f') }
149
- end
150
- context 'when invalid dependency', dependency: true do
151
- yaml = <<-"YAML"
152
- stacks:
153
- Test:
154
- template_file: vpc.yaml
155
- parameter_input: vpc.json
156
- timeout_in_minutes: 2
157
- depends:
158
- - Test2
159
- Test2:
160
- template_file: sg.yaml
161
- parameter_input: sg.json
162
- YAML
163
-
164
- before(:each) { write_file(file, yaml) }
165
- before(:each) { copy('%/vpc.yaml', 'vpc.yaml') }
166
- before(:each) { copy('%/vpc.json', 'vpc.json') }
167
- before(:each) { copy('%/sg.yaml', 'sg.yaml') }
168
- before(:each) { copy('%/sg.json', 'sg.json') }
169
- before(:each) { run_command('cfndk stack create') }
170
- it do
171
- aggregate_failures do
172
- expect(last_command_started).to have_exit_status(1)
173
- expect(last_command_started).to have_output(/ERROR stopped waiting, encountered a failure state$/)
174
- end
175
- end
176
- after(:each) { run_command('cfndk destroy -f') }
177
- end
178
- context 'when cyclic dependency', dependency: true do
179
- yaml = <<-"YAML"
180
- stacks:
181
- Test:
182
- template_file: vpc.yaml
183
- parameter_input: vpc.json
184
- timeout_in_minutes: 2
185
- depends:
186
- - Test2
187
- Test2:
188
- template_file: sg.yaml
189
- parameter_input: sg.json
190
- depends:
191
- - Test
192
- YAML
193
-
194
- before(:each) { write_file(file, yaml) }
195
- before(:each) { copy('%/vpc.yaml', 'vpc.yaml') }
196
- before(:each) { copy('%/vpc.json', 'vpc.json') }
197
- before(:each) { copy('%/sg.yaml', 'sg.yaml') }
198
- before(:each) { copy('%/sg.json', 'sg.json') }
199
- before(:each) { run_command('cfndk stack create') }
200
- it do
201
- aggregate_failures do
202
- expect(last_command_started).to have_exit_status(1)
203
- expect(last_command_started).to have_output(/ERROR There are cyclic dependency or stack doesn't exist. unprocessed_stack: Test,Test2$/)
204
- end
205
- end
206
- after(:each) { run_command('cfndk destroy -f') }
207
- end
208
- context 'when requires capabilities without capabilities', capabilities: true do
209
- yaml = <<-"YAML"
210
- stacks:
211
- Test:
212
- template_file: iam.yaml
213
- parameter_input: iam.json
214
- timeout_in_minutes: 2
215
- YAML
216
-
217
- before(:each) { write_file(file, yaml) }
218
- before(:each) { copy('%/iam.yaml', 'iam.yaml') }
219
- before(:each) { copy('%/iam.json', 'iam.json') }
220
- before(:each) { run_command('cfndk stack create') }
221
- it do
222
- aggregate_failures do
223
- expect(last_command_started).to have_exit_status(1)
224
- expect(last_command_started).to have_output(/ERROR Requires capabilities : \[CAPABILITY_NAMED_IAM\]/)
225
- end
226
- end
227
- after(:each) { run_command('cfndk destroy -f') }
228
- end
229
- context 'when success with capabilities', capabilities: true do
230
- yaml = <<-"YAML"
231
- stacks:
232
- Test:
233
- template_file: iam.yaml
234
- parameter_input: iam.json
235
- capabilities:
236
- - CAPABILITY_NAMED_IAM
237
- timeout_in_minutes: 3
238
- YAML
239
-
240
- before(:each) { write_file(file, yaml) }
241
- before(:each) { copy('%/iam.yaml', 'iam.yaml') }
242
- before(:each) { copy('%/iam.json', 'iam.json') }
243
- before(:each) { run_command('cfndk stack create') }
244
- it do
245
- aggregate_failures do
246
- expect(last_command_started).to be_successfully_executed
247
- expect(last_command_started).to have_output(/INFO created stack: Test$/)
248
- end
249
- end
250
- after(:each) { run_command('cfndk destroy -f') }
251
- end
252
- context 'with UUID', uuid: true do
253
- context 'when -u 38437346-c75c-47c5-83b4-d504f85e275b' do
254
- yaml = <<-"YAML"
255
- stacks:
256
- Test:
257
- template_file: vpc.yaml
258
- parameter_input: vpc.json
259
- parameters:
260
- VpcName: sample<%= append_uuid%>
261
- timeout_in_minutes: 2
262
- Test2:
263
- template_file: sg.yaml
264
- parameter_input: sg.json
265
- parameters:
266
- VpcName: sample<%= append_uuid%>
267
- depends:
268
- - Test
269
- YAML
270
- before(:each) { write_file(file, yaml) }
271
- before(:each) { copy('%/vpc.yaml', 'vpc.yaml') }
272
- before(:each) { copy('%/vpc.json', 'vpc.json') }
273
- before(:each) { copy('%/sg.yaml', 'sg.yaml') }
274
- before(:each) { copy('%/sg.json', 'sg.json') }
275
- before(:each) { run_command("cfndk stack create -u=#{uuid}") }
276
- it do
277
- aggregate_failures do
278
- expect(last_command_started).to be_successfully_executed
279
- expect(last_command_started).to have_output(/INFO validate stack: Test-#{uuid}$/)
280
- expect(last_command_started).to have_output(/INFO creating stack: Test-#{uuid}$/)
281
- expect(last_command_started).to have_output(/INFO created stack: Test-#{uuid}$/)
282
- expect(last_command_started).to have_output(/INFO validate stack: Test2-#{uuid}$/)
283
- expect(last_command_started).to have_output(/INFO creating stack: Test2-#{uuid}$/)
284
- expect(last_command_started).to have_output(/INFO created stack: Test2-#{uuid}$/)
285
- end
286
- end
287
- after(:each) { run_command("cfndk destroy -f -u=#{uuid}") }
288
- end
289
- context 'when env CFNDK_UUID=38437346-c75c-47c5-83b4-d504f85e275b' do
290
- before(:each) { set_environment_variable('CFNDK_UUID', uuid) }
291
- context 'with two stacks' do
292
- yaml = <<-"YAML"
293
- stacks:
294
- Test:
295
- template_file: vpc.yaml
296
- parameter_input: vpc.json
297
- parameters:
298
- VpcName: sample<%= append_uuid%>
299
- timeout_in_minutes: 2
300
- Test2:
301
- template_file: sg.yaml
302
- parameter_input: sg.json
303
- parameters:
304
- VpcName: sample<%= append_uuid%>
305
- depends:
306
- - Test
307
- YAML
308
- before(:each) { write_file(file, yaml) }
309
- before(:each) { copy('%/vpc.yaml', 'vpc.yaml') }
310
- before(:each) { copy('%/vpc.json', 'vpc.json') }
311
- before(:each) { copy('%/sg.yaml', 'sg.yaml') }
312
- before(:each) { copy('%/sg.json', 'sg.json') }
313
- before(:each) { run_command('cfndk stack create') }
314
- it do
315
- aggregate_failures do
316
- expect(last_command_started).to be_successfully_executed
317
- expect(last_command_started).to have_output(/INFO validate stack: Test-#{uuid}$/)
318
- expect(last_command_started).to have_output(/INFO creating stack: Test-#{uuid}$/)
319
- expect(last_command_started).to have_output(/INFO created stack: Test-#{uuid}$/)
320
- expect(last_command_started).to have_output(/INFO validate stack: Test2-#{uuid}$/)
321
- expect(last_command_started).to have_output(/INFO creating stack: Test2-#{uuid}$/)
322
- expect(last_command_started).to have_output(/INFO created stack: Test2-#{uuid}$/)
323
- end
324
- end
325
- after(:each) { run_command('cfndk destroy -f') }
326
- end
327
- context 'when --stack-names=Test' do
328
- yaml = <<-"YAML"
329
- stacks:
330
- Test:
331
- template_file: vpc.yaml
332
- parameter_input: vpc.json
333
- parameters:
334
- VpcName: sample<%= append_uuid%>
335
- timeout_in_minutes: 2
336
- Test2:
337
- template_file: sg.yaml
338
- parameter_input: sg.json
339
- parameters:
340
- VpcName: sample<%= append_uuid%>
341
- depends:
342
- - Test
343
- YAML
344
- before(:each) { write_file(file, yaml) }
345
- before(:each) { copy('%/vpc.yaml', 'vpc.yaml') }
346
- before(:each) { copy('%/vpc.json', 'vpc.json') }
347
- before(:each) { copy('%/sg.yaml', 'sg.yaml') }
348
- before(:each) { copy('%/sg.json', 'sg.json') }
349
- before(:each) { run_command('cfndk stack create --stack-names=Test') }
350
- it do
351
- aggregate_failures do
352
- expect(last_command_started).to be_successfully_executed
353
- expect(last_command_started).to have_output(/INFO create.../)
354
- expect(last_command_started).to have_output(/INFO validate stack: Test-#{uuid}$/)
355
- expect(last_command_started).to have_output(/INFO creating stack: Test-#{uuid}$/)
356
- expect(last_command_started).to have_output(/INFO created stack: Test-#{uuid}$/)
357
- expect(last_command_started).not_to have_output(/INFO validate stack: Test2-#{uuid}$/)
358
- expect(last_command_started).not_to have_output(/INFO creating stack: Test2-#{uuid}$/)
359
- expect(last_command_started).not_to have_output(/INFO created stack: Test2-#{uuid}$/)
360
- end
361
- end
362
- after(:each) { run_command('cfndk destroy -f') }
363
- end
364
- context 'when --stack-names=Test Test2' do
365
- yaml = <<-"YAML"
366
- stacks:
367
- Test:
368
- template_file: vpc.yaml
369
- parameter_input: vpc.json
370
- parameters:
371
- VpcName: sample<%= append_uuid%>
372
- timeout_in_minutes: 2
373
- Test2:
374
- template_file: sg.yaml
375
- parameter_input: sg.json
376
- parameters:
377
- VpcName: sample<%= append_uuid%>
378
- depends:
379
- - Test
380
- Test3:
381
- template_file: iam.yaml
382
- parameter_input: iam.json
383
- parameters:
384
- WebRoleName: WebhRole<%= append_uuid%>
385
- capabilities:
386
- - CAPABILITY_NAMED_IAM
387
- timeout_in_minutes: 3
388
- YAML
389
- before(:each) { write_file(file, yaml) }
390
- before(:each) { copy('%/vpc.yaml', 'vpc.yaml') }
391
- before(:each) { copy('%/vpc.json', 'vpc.json') }
392
- before(:each) { copy('%/sg.yaml', 'sg.yaml') }
393
- before(:each) { copy('%/sg.json', 'sg.json') }
394
- before(:each) { copy('%/iam.yaml', 'iam.yaml') }
395
- before(:each) { copy('%/iam.json', 'iam.json') }
396
- before(:each) { run_command('cfndk stack create --stack-names=Test Test2') }
397
- it do
398
- aggregate_failures do
399
- expect(last_command_started).to be_successfully_executed
400
- expect(last_command_started).to have_output(/INFO create.../)
401
- expect(last_command_started).to have_output(/INFO validate stack: Test-#{uuid}$/)
402
- expect(last_command_started).to have_output(/INFO creating stack: Test-#{uuid}$/)
403
- expect(last_command_started).to have_output(/INFO created stack: Test-#{uuid}$/)
404
- expect(last_command_started).to have_output(/INFO validate stack: Test2-#{uuid}$/)
405
- expect(last_command_started).to have_output(/INFO creating stack: Test2-#{uuid}$/)
406
- expect(last_command_started).to have_output(/INFO created stack: Test2-#{uuid}$/)
407
- expect(last_command_started).not_to have_output(/INFO validate stack: Test3-#{uuid}$/)
408
- expect(last_command_started).not_to have_output(/INFO creating stack: Test3-#{uuid}$/)
409
- expect(last_command_started).not_to have_output(/INFO created stack: Test3-#{uuid}$/)
410
- end
411
- end
412
- after(:each) { run_command('cfndk destroy -f') }
413
- end
414
- end
415
- end
416
- end
417
- end
418
- end
419
-
420
- describe 'destroy', destroy: true do
421
- context 'when -f without cfndk.yml' do
422
- before(:each) { run_command('cfndk stack destroy -f') }
423
- it 'displays file does not exist error and status code = 1' do
424
- aggregate_failures do
425
- expect(last_command_started).to have_exit_status(1)
426
- expect(last_command_started).to have_output(/ERROR File does not exist./)
427
- end
428
- end
429
- end
430
-
431
- context 'with cfndk2.yml' do
432
- yaml = <<-"YAML"
433
- stacks:
434
- YAML
435
- before(:each) { write_file(file2, yaml) }
436
- context 'when -c cfndk2.yml -f and empty stacks' do
437
- before(:each) { run_command("cfndk stack destroy -c=#{file2} -f") }
438
- it 'displays empty stack log' do
439
- aggregate_failures do
440
- expect(last_command_started).to be_successfully_executed
441
- expect(last_command_started).to have_output(/INFO destroy.../)
442
- end
443
- end
444
- end
445
-
446
- context 'when --config-path cfndk2.yml -f and empty stacks' do
447
- before(:each) { run_command("cfndk stack destroy --config-path=#{file2} -f") }
448
- it 'displays empty stack log' do
449
- aggregate_failures do
450
- expect(last_command_started).to be_successfully_executed
451
- expect(last_command_started).to have_output(/INFO destroy.../)
452
- end
453
- end
454
- end
455
- end
456
-
457
- context 'with cfndk.yml' do
458
- context 'when cfndk.yml is empty' do
459
- before(:each) { touch(file) }
460
- before(:each) { run_command('cfndk stack destroy -f') }
461
- it 'displays File is empty error and status code = 1' do
462
- aggregate_failures do
463
- expect(last_command_started).to have_exit_status(1)
464
- expect(last_command_started).to have_output(/ERROR File is empty./)
465
- end
466
- end
467
- end
468
- context 'when enter no' do
469
- yaml = <<-"YAML"
470
- keypairs:
471
- Test1:
472
- stacks:
473
- Test:
474
- template_file: vpc.yaml
475
- parameter_input: vpc.json
476
- parameters:
477
- VpcName: sample<%= append_uuid%>
478
- timeout_in_minutes: 2
479
- YAML
480
- before(:each) { write_file(file, yaml) }
481
- before(:each) { copy('%/vpc.yaml', 'vpc.yaml') }
482
- before(:each) { copy('%/vpc.json', 'vpc.json') }
483
- before(:each) { run_command('cfndk stack destroy') }
484
- before(:each) { type('no') }
485
- it 'displays confirm message and cancel message and status code = 2' do
486
- aggregate_failures do
487
- expect(last_command_started).to have_exit_status(2)
488
- expect(last_command_started).to have_output(/INFO destroy../)
489
- expect(last_command_started).to have_output(%r{Are you sure you want to destroy\? \(y/n\)})
490
- expect(last_command_started).to have_output(/INFO destroy command was canceled/)
491
- expect(last_command_started).not_to have_output(/INFO deleting stack:/)
492
- expect(last_command_started).not_to have_output(/INFO deleted stack:/)
493
- expect(last_command_started).not_to have_output(/INFO do not delete keypair: Test1$/)
494
- expect(last_command_started).not_to have_output(/INFO do not delete stack: Test$/)
495
- end
496
- end
497
- end
498
- context 'when enter yes' do
499
- context 'when keyparis and stacks do not exist' do
500
- yaml = <<-"YAML"
501
- keypairs:
502
- Test1:
503
- stacks:
504
- Test:
505
- template_file: vpc.yaml
506
- parameter_input: vpc.json
507
- parameters:
508
- VpcName: sample<%= append_uuid%>
509
- timeout_in_minutes: 2
510
- YAML
511
- before(:each) { write_file(file, yaml) }
512
- before(:each) { copy('%/vpc.yaml', 'vpc.yaml') }
513
- before(:each) { copy('%/vpc.json', 'vpc.json') }
514
- before(:each) { run_command('cfndk destroy -f') }
515
- before(:each) { stop_all_commands }
516
- before(:each) { run_command('cfndk stack destroy') }
517
- before(:each) { type('yes') }
518
- before(:each) { stop_all_commands }
519
- it 'displays confirm message and do not delete message' do
520
- aggregate_failures do
521
- expect(last_command_started).to be_successfully_executed
522
- expect(last_command_started).to have_output(/INFO destroy../)
523
- expect(last_command_started).to have_output(%r{Are you sure you want to destroy\? \(y/n\)})
524
- expect(last_command_started).not_to have_output(/INFO do not delete keypair: Test1$/)
525
- expect(last_command_started).to have_output(/INFO do not delete stack: Test$/)
526
- end
527
- end
528
- end
529
- context 'when keyparis and stacks exist' do
530
- yaml = <<-"YAML"
531
- keypairs:
532
- Test1:
533
- stacks:
534
- Test:
535
- template_file: vpc.yaml
536
- parameter_input: vpc.json
537
- parameters:
538
- VpcName: sample<%= append_uuid%>
539
- timeout_in_minutes: 2
540
- YAML
541
- before(:each) { write_file(file, yaml) }
542
- before(:each) { copy('%/vpc.yaml', 'vpc.yaml') }
543
- before(:each) { copy('%/vpc.json', 'vpc.json') }
544
- before(:each) { run_command('cfndk create') }
545
- before(:each) { stop_all_commands }
546
- before(:each) { run_command('cfndk stack destroy') }
547
- before(:each) { type('yes') }
548
- before(:each) { stop_all_commands }
549
- it 'displays confirm message and delete message' do
550
- aggregate_failures do
551
- expect(last_command_started).to be_successfully_executed
552
- expect(last_command_started).to have_output(/INFO destroy../)
553
- expect(last_command_started).to have_output(%r{Are you sure you want to destroy\? \(y/n\)})
554
- expect(last_command_started).not_to have_output(/INFO deleted keypair: Test1$/)
555
- expect(last_command_started).to have_output(/INFO deleted stack: Test$/)
556
- end
557
- end
558
- after(:each) { run_command('cfndk destroy -f') }
559
- end
560
- end
561
- end
562
- end
563
-
564
- describe 'update', update: true do
565
- context 'without cfndk.yml' do
566
- before(:each) { run_command('cfndk stack update') }
567
- it 'displays file does not exist error and status code = 1' do
568
- aggregate_failures do
569
- expect(last_command_started).to have_exit_status(1)
570
- expect(last_command_started).to have_output(/ERROR File does not exist./)
571
- end
572
- end
573
- end
574
-
575
- context 'with cfndk2.yml' do
576
- yaml = <<-"YAML"
577
- keypairs:
578
- YAML
579
- before(:each) { write_file(file2, yaml) }
580
- context 'when -c cfndk2.yml and empty stacks' do
581
- before(:each) { run_command("cfndk stack update -c=#{file2}") }
582
- it 'displays empty stack log' do
583
- aggregate_failures do
584
- expect(last_command_started).to be_successfully_executed
585
- expect(last_command_started).to have_output(/INFO update.../)
586
- end
587
- end
588
- end
589
-
590
- context 'when --config-path cfndk2.yml and empty stacks' do
591
- before(:each) { run_command("cfndk stack update --config-path=#{file2}") }
592
- it 'displays empty stack log' do
593
- aggregate_failures do
594
- expect(last_command_started).to be_successfully_executed
595
- expect(last_command_started).to have_output(/INFO update.../)
596
- end
597
- end
598
- end
599
- end
600
-
601
- context 'with cfndk.yml' do
602
- context 'when cfndk.yml is empty' do
603
- before(:each) { touch(file) }
604
- before(:each) { run_command('cfndk stack update') }
605
- it 'displays File is empty error and status code = 1' do
606
- aggregate_failures do
607
- expect(last_command_started).to have_exit_status(1)
608
- expect(last_command_started).to have_output(/ERROR File is empty./)
609
- end
610
- end
611
- end
612
- context 'when empty yaml' do
613
- yaml = <<-"YAML"
614
- stacks:
615
- Test:
616
- template_file: vpc.yaml
617
- timeout_in_minutes: 2
618
- YAML
619
- before(:each) { write_file(file, yaml) }
620
- before(:each) { copy('%/empty_resource.yaml', 'vpc.yaml') }
621
- before(:each) { run_command('cfndk stack update') }
622
- it 'Displays error message and status code = 1' do
623
- aggregate_failures do
624
- expect(last_command_started).to have_exit_status(1)
625
- expect(last_command_started).to have_output(/INFO validate stack: Test$/)
626
- expect(last_command_started).to have_output(/ERROR Template format error: At least one Resources member must be defined\.$/)
627
- end
628
- end
629
- end
630
- context 'when invalid yaml' do
631
- yaml = <<-"YAML"
632
- stacks:
633
- Test:
634
- template_file: vpc.yaml
635
- parameter_input: vpc.json
636
- timeout_in_minutes: 2
637
- YAML
638
- before(:each) { write_file(file, yaml) }
639
- before(:each) { copy('%/invalid_vpc.yaml', 'vpc.yaml') }
640
- before(:each) { copy('%/vpc.json', 'vpc.json') }
641
- before(:each) { run_command('cfndk stack update') }
642
- it 'Displays error message and status code = 1' do
643
- aggregate_failures do
644
- expect(last_command_started).to have_exit_status(1)
645
- expect(last_command_started).to have_output(/INFO validate stack: Test$/)
646
- expect(last_command_started).to have_output(/ERROR \[\/Resources\] 'null' values are not allowed in templates$/)
647
- end
648
- end
649
- end
650
-
651
- context 'with stacks:' do
652
- context 'without stack' do
653
- before(:each) { write_file(file, 'stacks:') }
654
- before(:each) { run_command('cfndk stack update') }
655
- it do
656
- aggregate_failures do
657
- expect(last_command_started).to be_successfully_executed
658
- expect(last_command_started).to have_output(/INFO update.../)
659
- end
660
- end
661
- end
662
-
663
- context 'with a stack', with_stack: true do
664
- yaml = <<-"YAML"
665
- stacks:
666
- Test:
667
- template_file: vpc.yaml
668
- parameter_input: vpc.json
669
- timeout_in_minutes: 2
670
- YAML
671
- before(:each) { write_file(file, yaml) }
672
- before(:each) { copy('%/vpc.yaml', 'vpc.yaml') }
673
- before(:each) { copy('%/vpc.json', 'vpc.json') }
674
- context 'when stack already exist' do
675
- context 'when same yaml' do
676
- before(:each) { run_command_and_stop('cfndk stack create') }
677
- before(:each) { run_command('cfndk stack update') }
678
- it 'displays No update warn' do
679
- aggregate_failures do
680
- expect(last_command_started).to have_exit_status(0)
681
- expect(last_command_started).to have_output(/INFO validate stack: Test$/)
682
- expect(last_command_started).to have_output(/INFO updating stack: Test$/)
683
- expect(last_command_started).to have_output(/WARN No updates are to be performed\.: Test$/)
684
- end
685
- end
686
- end
687
- context 'when different yaml' do
688
- before(:each) { run_command_and_stop('cfndk stack create') }
689
- before(:each) { copy('%/vpc_different.yaml', 'vpc.yaml') }
690
- before(:each) { run_command('cfndk stack update') }
691
- it 'displays update log' do
692
- aggregate_failures do
693
- expect(last_command_started).to be_successfully_executed
694
- expect(last_command_started).to have_output(/INFO validate stack: Test$/)
695
- expect(last_command_started).to have_output(/INFO updating stack: Test$/)
696
- expect(last_command_started).to have_output(/INFO updated stack: Test$/)
697
- end
698
- end
699
- end
700
- end
701
- context 'when stack does not exist' do
702
- before(:each) { run_command('cfndk stack update') }
703
- it 'displays no stack error and statu code = 1' do
704
- aggregate_failures do
705
- expect(last_command_started).to have_exit_status(1)
706
- expect(last_command_started).to have_output(/INFO validate stack: Test$/)
707
- expect(last_command_started).to have_output(/INFO updating stack: Test$/)
708
- expect(last_command_started).to have_output(/ERROR Stack \[Test\] does not exist$/)
709
- end
710
- end
711
- end
712
- after(:each) { run_command('cfndk destroy -f') }
713
- end
714
- context 'with two stacks' do
715
- yaml = <<-"YAML"
716
- stacks:
717
- Test:
718
- template_file: vpc.yaml
719
- parameter_input: vpc.json
720
- timeout_in_minutes: 4
721
- Test2:
722
- template_file: sg.yaml
723
- parameter_input: sg.json
724
- depends:
725
- - Test
726
- YAML
727
- before(:each) { write_file(file, yaml) }
728
- before(:each) { copy('%/vpc.yaml', 'vpc.yaml') }
729
- before(:each) { copy('%/vpc.json', 'vpc.json') }
730
- before(:each) { copy('%/sg.yaml', 'sg.yaml') }
731
- before(:each) { copy('%/sg.json', 'sg.json') }
732
- before(:each) { run_command_and_stop('cfndk stack create') }
733
- before(:each) { copy('%/sg_different.yaml', 'sg.yaml') }
734
- before(:each) { run_command('cfndk stack update') }
735
- it 'displays updated logs' do
736
- aggregate_failures do
737
- expect(last_command_started).to be_successfully_executed
738
- expect(last_command_started).to have_output(/INFO validate stack: Test$/)
739
- expect(last_command_started).to have_output(/INFO updating stack: Test$/)
740
- expect(last_command_started).to have_output(/WARN No updates are to be performed.: Test$/)
741
- expect(last_command_started).to have_output(/INFO validate stack: Test2$/)
742
- expect(last_command_started).to have_output(/INFO updating stack: Test2$/)
743
- expect(last_command_started).to have_output(/INFO updated stack: Test2$/)
744
- end
745
- end
746
- after(:each) { run_command('cfndk destroy -f') }
747
- end
748
- context 'when cyclic dependency', dependency: true do
749
- yaml = <<-"YAML"
750
- stacks:
751
- Test:
752
- template_file: vpc.yaml
753
- parameter_input: vpc.json
754
- timeout_in_minutes: 2
755
- depends:
756
- - Test2
757
- Test2:
758
- template_file: sg.yaml
759
- parameter_input: sg.json
760
- depends:
761
- - Test
762
- YAML
763
-
764
- before(:each) { write_file(file, yaml) }
765
- before(:each) { copy('%/vpc.yaml', 'vpc.yaml') }
766
- before(:each) { copy('%/vpc.json', 'vpc.json') }
767
- before(:each) { copy('%/sg.yaml', 'sg.yaml') }
768
- before(:each) { copy('%/sg.json', 'sg.json') }
769
- before(:each) { run_command('cfndk stack update') }
770
- it 'displays cyclic error log and exit status = 1' do
771
- aggregate_failures do
772
- expect(last_command_started).to have_exit_status(1)
773
- expect(last_command_started).to have_output(/ERROR There are cyclic dependency or stack doesn't exist. unprocessed_stack: Test,Test2$/)
774
- end
775
- end
776
- after(:each) { run_command('cfndk destroy -f') }
777
- end
778
- context 'when requires capabilities without capabilities', capabilities: true do
779
- yaml = <<-"YAML"
780
- stacks:
781
- Test:
782
- template_file: iam.yaml
783
- parameter_input: iam.json
784
- capabilities:
785
- - CAPABILITY_NAMED_IAM
786
- timeout_in_minutes: 3
787
- YAML
788
- yaml2 = <<-"YAML"
789
- stacks:
790
- Test:
791
- template_file: iam.yaml
792
- parameter_input: iam.json
793
- timeout_in_minutes: 2
794
- YAML
795
- before(:each) { write_file(file, yaml) }
796
- before(:each) { copy('%/iam.yaml', 'iam.yaml') }
797
- before(:each) { copy('%/iam.json', 'iam.json') }
798
- before(:each) { run_command_and_stop('cfndk stack create') }
799
- before(:each) { write_file(file, yaml2) }
800
- before(:each) { run_command('cfndk stack update') }
801
- it 'displays Requires capabilities log and exit status = 1' do
802
- aggregate_failures do
803
- expect(last_command_started).to have_exit_status(1)
804
- expect(last_command_started).to have_output(/ERROR Requires capabilities : \[CAPABILITY_NAMED_IAM\]/)
805
- end
806
- end
807
- after(:each) { run_command('cfndk destroy -f') }
808
- end
809
- context 'when success with capabilities', capabilities: true do
810
- yaml = <<-"YAML"
811
- stacks:
812
- Test:
813
- template_file: iam.yaml
814
- parameter_input: iam.json
815
- capabilities:
816
- - CAPABILITY_NAMED_IAM
817
- timeout_in_minutes: 3
818
- YAML
819
-
820
- before(:each) { write_file(file, yaml) }
821
- before(:each) { copy('%/iam.yaml', 'iam.yaml') }
822
- before(:each) { copy('%/iam.json', 'iam.json') }
823
- before(:each) { run_command_and_stop('cfndk stack create') }
824
- before(:each) { copy('%/iam_different.json', 'iam.json') }
825
- before(:each) { run_command('cfndk stack update') }
826
- it 'displays updated log' do
827
- aggregate_failures do
828
- expect(last_command_started).to be_successfully_executed
829
- expect(last_command_started).to have_output(/INFO updated stack: Test$/)
830
- end
831
- end
832
- after(:each) { run_command('cfndk destroy -f') }
833
- end
834
- context 'with UUID', uuid: true do
835
- context 'when -u 38437346-c75c-47c5-83b4-d504f85e275b' do
836
- yaml = <<-"YAML"
837
- stacks:
838
- Test:
839
- template_file: vpc.yaml
840
- parameter_input: vpc.json
841
- parameters:
842
- VpcName: sample<%= append_uuid%>
843
- timeout_in_minutes: 2
844
- Test2:
845
- template_file: sg.yaml
846
- parameter_input: sg.json
847
- parameters:
848
- VpcName: sample<%= append_uuid%>
849
- depends:
850
- - Test
851
- YAML
852
- before(:each) { write_file(file, yaml) }
853
- before(:each) { copy('%/vpc.yaml', 'vpc.yaml') }
854
- before(:each) { copy('%/vpc.json', 'vpc.json') }
855
- before(:each) { copy('%/sg.yaml', 'sg.yaml') }
856
- before(:each) { copy('%/sg.json', 'sg.json') }
857
- before(:each) { run_command_and_stop("cfndk stack create -u=#{uuid}") }
858
- before(:each) { copy('%/vpc_different.yaml', 'vpc.yaml') }
859
- before(:each) { copy('%/sg_different.yaml', 'sg.yaml') }
860
- before(:each) { run_command("cfndk stack update -u=#{uuid}") }
861
- it 'displays updated logs' do
862
- aggregate_failures do
863
- expect(last_command_started).to be_successfully_executed
864
- expect(last_command_started).to have_output(/INFO validate stack: Test-#{uuid}$/)
865
- expect(last_command_started).to have_output(/INFO updating stack: Test-#{uuid}$/)
866
- expect(last_command_started).to have_output(/INFO updated stack: Test-#{uuid}$/)
867
- expect(last_command_started).to have_output(/INFO validate stack: Test2-#{uuid}$/)
868
- expect(last_command_started).to have_output(/INFO updating stack: Test2-#{uuid}$/)
869
- expect(last_command_started).to have_output(/INFO updated stack: Test2-#{uuid}$/)
870
- end
871
- end
872
- after(:each) { run_command("cfndk destroy -f -u=#{uuid}") }
873
- end
874
- context 'when env CFNDK_UUID=38437346-c75c-47c5-83b4-d504f85e275b' do
875
- before(:each) { set_environment_variable('CFNDK_UUID', uuid) }
876
- context 'with two stacks' do
877
- yaml = <<-"YAML"
878
- stacks:
879
- Test:
880
- template_file: vpc.yaml
881
- parameter_input: vpc.json
882
- parameters:
883
- VpcName: sample<%= append_uuid%>
884
- timeout_in_minutes: 2
885
- Test2:
886
- template_file: sg.yaml
887
- parameter_input: sg.json
888
- parameters:
889
- VpcName: sample<%= append_uuid%>
890
- depends:
891
- - Test
892
- YAML
893
- before(:each) { write_file(file, yaml) }
894
- before(:each) { copy('%/vpc.yaml', 'vpc.yaml') }
895
- before(:each) { copy('%/vpc.json', 'vpc.json') }
896
- before(:each) { copy('%/sg.yaml', 'sg.yaml') }
897
- before(:each) { copy('%/sg.json', 'sg.json') }
898
- before(:each) { run_command_and_stop('cfndk stack create') }
899
- before(:each) { copy('%/vpc_different.yaml', 'vpc.yaml') }
900
- before(:each) { copy('%/sg_different.yaml', 'sg.yaml') }
901
- before(:each) { run_command('cfndk stack update') }
902
- it 'displays updated logs' do
903
- aggregate_failures do
904
- expect(last_command_started).to be_successfully_executed
905
- expect(last_command_started).to have_output(/INFO validate stack: Test-#{uuid}$/)
906
- expect(last_command_started).to have_output(/INFO updating stack: Test-#{uuid}$/)
907
- expect(last_command_started).to have_output(/INFO updated stack: Test-#{uuid}$/)
908
- expect(last_command_started).to have_output(/INFO validate stack: Test2-#{uuid}$/)
909
- expect(last_command_started).to have_output(/INFO updating stack: Test2-#{uuid}$/)
910
- expect(last_command_started).to have_output(/INFO updated stack: Test2-#{uuid}$/)
911
- end
912
- end
913
- after(:each) { run_command('cfndk destroy -f') }
914
- end
915
- context 'when --stack-names=Test' do
916
- yaml = <<-"YAML"
917
- stacks:
918
- Test:
919
- template_file: vpc.yaml
920
- parameter_input: vpc.json
921
- parameters:
922
- VpcName: sample<%= append_uuid%>
923
- timeout_in_minutes: 2
924
- Test2:
925
- template_file: sg.yaml
926
- parameter_input: sg.json
927
- parameters:
928
- VpcName: sample<%= append_uuid%>
929
- depends:
930
- - Test
931
- YAML
932
- before(:each) { write_file(file, yaml) }
933
- before(:each) { copy('%/vpc.yaml', 'vpc.yaml') }
934
- before(:each) { copy('%/vpc.json', 'vpc.json') }
935
- before(:each) { copy('%/sg.yaml', 'sg.yaml') }
936
- before(:each) { copy('%/sg.json', 'sg.json') }
937
- before(:each) { run_command_and_stop('cfndk stack create') }
938
- before(:each) { copy('%/vpc_different.yaml', 'vpc.yaml') }
939
- before(:each) { run_command('cfndk stack update --stack-names=Test') }
940
- it 'displays updated log of Test stack' do
941
- aggregate_failures do
942
- expect(last_command_started).to be_successfully_executed
943
- expect(last_command_started).to have_output(/INFO update.../)
944
- expect(last_command_started).to have_output(/INFO validate stack: Test-#{uuid}$/)
945
- expect(last_command_started).to have_output(/INFO updating stack: Test-#{uuid}$/)
946
- expect(last_command_started).to have_output(/INFO updated stack: Test-#{uuid}$/)
947
- expect(last_command_started).not_to have_output(/INFO validate stack: Test2-#{uuid}$/)
948
- expect(last_command_started).not_to have_output(/INFO updating stack: Test2-#{uuid}$/)
949
- expect(last_command_started).not_to have_output(/INFO updated stack: Test2-#{uuid}$/)
950
- end
951
- end
952
- after(:each) { run_command('cfndk destroy -f') }
953
- end
954
- context 'when --stack-names=Test Test2' do
955
- yaml = <<-"YAML"
956
- stacks:
957
- Test:
958
- template_file: vpc.yaml
959
- parameter_input: vpc.json
960
- parameters:
961
- VpcName: sample<%= append_uuid%>
962
- timeout_in_minutes: 2
963
- Test2:
964
- template_file: sg.yaml
965
- parameter_input: sg.json
966
- parameters:
967
- VpcName: sample<%= append_uuid%>
968
- depends:
969
- - Test
970
- Test3:
971
- template_file: iam.yaml
972
- parameter_input: iam.json
973
- parameters:
974
- WebRoleName: WebhRole<%= append_uuid%>
975
- capabilities:
976
- - CAPABILITY_NAMED_IAM
977
- timeout_in_minutes: 3
978
- YAML
979
- before(:each) { write_file(file, yaml) }
980
- before(:each) { copy('%/vpc.yaml', 'vpc.yaml') }
981
- before(:each) { copy('%/vpc.json', 'vpc.json') }
982
- before(:each) { copy('%/sg.yaml', 'sg.yaml') }
983
- before(:each) { copy('%/sg.json', 'sg.json') }
984
- before(:each) { copy('%/iam.yaml', 'iam.yaml') }
985
- before(:each) { copy('%/iam.json', 'iam.json') }
986
- before(:each) { run_command_and_stop('cfndk stack create') }
987
- before(:each) { copy('%/vpc_different.yaml', 'vpc.yaml') }
988
- before(:each) { copy('%/sg_different.yaml', 'sg.yaml') }
989
- before(:each) { run_command('cfndk stack update --stack-names=Test Test2') }
990
- it 'displays updated logs of Test1/Test2 stacks' do
991
- aggregate_failures do
992
- expect(last_command_started).to be_successfully_executed
993
- expect(last_command_started).to have_output(/INFO update.../)
994
- expect(last_command_started).to have_output(/INFO validate stack: Test-#{uuid}$/)
995
- expect(last_command_started).to have_output(/INFO updating stack: Test-#{uuid}$/)
996
- expect(last_command_started).to have_output(/INFO updated stack: Test-#{uuid}$/)
997
- expect(last_command_started).to have_output(/INFO validate stack: Test2-#{uuid}$/)
998
- expect(last_command_started).to have_output(/INFO updating stack: Test2-#{uuid}$/)
999
- expect(last_command_started).to have_output(/INFO updated stack: Test2-#{uuid}$/)
1000
- expect(last_command_started).not_to have_output(/INFO validate stack: Test3-#{uuid}$/)
1001
- expect(last_command_started).not_to have_output(/INFO updating stack: Test3-#{uuid}$/)
1002
- expect(last_command_started).not_to have_output(/INFO updated stack: Test3-#{uuid}$/)
1003
- end
1004
- end
1005
- after(:each) { run_command('cfndk destroy -f') }
1006
- end
1007
- end
1008
- end
1009
- end
1010
- end
1011
- end
1012
-
1013
36
  describe 'validate', validate: true do
1014
37
  context 'without cfndk.yml' do
1015
38
  before(:each) { run_command('cfndk stack validate') }
1016
39
  it 'displays file does not exist error and status code = 1' do
1017
40
  aggregate_failures do
1018
41
  expect(last_command_started).to have_exit_status(1)
1019
- expect(last_command_started).to have_output(/ERROR File does not exist./)
42
+ expect(last_command_started).to have_output(/ERROR RuntimeError: File does not exist./)
1020
43
  end
1021
44
  end
1022
45
  end
@@ -1034,7 +57,7 @@ RSpec.describe 'CFnDK', type: :aruba do
1034
57
  expect(last_command_started).to have_output(/INFO validate.../)
1035
58
  end
1036
59
  end
1037
- end
60
+ end
1038
61
  context 'when --config-path cfndk2.yml and empty stacks' do
1039
62
  before(:each) { run_command("cfndk stack validate --config-path=#{file2}") }
1040
63
  it 'displays empty stack log' do
@@ -1079,7 +102,7 @@ RSpec.describe 'CFnDK', type: :aruba do
1079
102
  aggregate_failures do
1080
103
  expect(last_command_started).to have_exit_status(1)
1081
104
  expect(last_command_started).to have_output(/INFO validate stack: Test$/)
1082
- expect(last_command_started).to have_output(/ERROR Template format error: At least one Resources member must be defined\.$/)
105
+ expect(last_command_started).to have_output(/ERROR Aws::CloudFormation::Errors::ValidationError: Template format error: At least one Resources member must be defined\.$/)
1083
106
  end
1084
107
  end
1085
108
  end
@@ -1099,171 +122,8 @@ RSpec.describe 'CFnDK', type: :aruba do
1099
122
  aggregate_failures do
1100
123
  expect(last_command_started).to have_exit_status(1)
1101
124
  expect(last_command_started).to have_output(/INFO validate stack: Test$/)
1102
- expect(last_command_started).to have_output(/ERROR \[\/Resources\] 'null' values are not allowed in templates$/)
1103
- end
1104
- end
1105
- end
1106
- end
1107
- end
1108
- describe 'report', report: true do
1109
- context 'without cfndk.yml' do
1110
- before(:each) { run_command('cfndk stack report') }
1111
- it 'displays file does not exist error and status code = 1' do
1112
- aggregate_failures do
1113
- expect(last_command_started).to have_exit_status(1)
1114
- expect(last_command_started).to have_output(/ERROR File does not exist./)
1115
- end
1116
- end
1117
- end
1118
-
1119
- context 'with cfndk2.yml' do
1120
- yaml = <<-"YAML"
1121
- keypairs:
1122
- YAML
1123
- before(:each) { write_file(file2, yaml) }
1124
- context 'when -c cfndk2.yml and empty stacks' do
1125
- before(:each) { run_command("cfndk stack report -c=#{file2}") }
1126
- it 'displays empty stack log' do
1127
- aggregate_failures do
1128
- expect(last_command_started).to be_successfully_executed
1129
- expect(last_command_started).to have_output(/INFO report.../)
1130
- end
1131
- end
1132
- end
1133
-
1134
- context 'when --config-path cfndk2.yml and empty stacks' do
1135
- before(:each) { run_command("cfndk stack report --config-path=#{file2}") }
1136
- it 'displays empty stack log' do
1137
- aggregate_failures do
1138
- expect(last_command_started).to be_successfully_executed
1139
- expect(last_command_started).to have_output(/INFO report.../)
1140
- end
1141
- end
1142
- end
1143
- end
1144
-
1145
- context 'with cfndk.yml' do
1146
- context 'when cfndk.yml is empty' do
1147
- before(:each) { touch('cfndk.yml') }
1148
- before(:each) { run_command('cfndk stack report') }
1149
- it 'displays File is empty error and status code = 1' do
1150
- aggregate_failures do
1151
- expect(last_command_started).to have_exit_status(1)
1152
- expect(last_command_started).to have_output(/ERROR File is empty./)
1153
- end
1154
- end
1155
- end
1156
-
1157
- context 'with empty keypairs and stacks' do
1158
- yaml = <<-"YAML"
1159
- keypairs:
1160
- stacks:
1161
- YAML
1162
- before(:each) { write_file('cfndk.yml', yaml) }
1163
- before(:each) { run_command('cfndk stack report') }
1164
- it 'displays empty stacks and keypairs report' do
1165
- aggregate_failures do
1166
- expect(last_command_started).to be_successfully_executed
1167
- expect(last_command_started).to have_output(/INFO report.../)
1168
- end
1169
- end
1170
- end
1171
-
1172
- context 'with keypairs and stacks' do
1173
- yaml = <<-"YAML"
1174
- keypairs:
1175
- Key1:
1176
- Key2:
1177
- stacks:
1178
- Test:
1179
- template_file: vpc.yaml
1180
- parameter_input: vpc.json
1181
- timeout_in_minutes: 2
1182
- Test2:
1183
- template_file: sg.yaml
1184
- parameter_input: sg.json
1185
- depends:
1186
- - Test
1187
- YAML
1188
- context 'without UUID' do
1189
- before(:each) { write_file('cfndk.yml', yaml) }
1190
- before(:each) { copy('%/vpc.yaml', 'vpc.yaml') }
1191
- before(:each) { copy('%/vpc.json', 'vpc.json') }
1192
- before(:each) { copy('%/sg.yaml', 'sg.yaml') }
1193
- before(:each) { copy('%/sg.json', 'sg.json') }
1194
- before(:each) { run_command_and_stop('cfndk create') }
1195
- context 'without option' do
1196
- before(:each) { run_command('cfndk stack report') }
1197
- it 'displays stacks report' do
1198
- aggregate_failures do
1199
- expect(last_command_started).to be_successfully_executed
1200
- expect(last_command_started).to have_output(/INFO stack: Test$/)
1201
- expect(last_command_started).to have_output(/INFO stack: Test2$/)
1202
- end
1203
- end
1204
- end
1205
- context 'when --stack-names Test2' do
1206
- before(:each) { run_command('cfndk stack report --stack-names Test2') }
1207
- it 'displays stacks report' do
1208
- aggregate_failures do
1209
- expect(last_command_started).to be_successfully_executed
1210
- expect(last_command_started).not_to have_output(/INFO stack: Test$/)
1211
- expect(last_command_started).to have_output(/INFO stack: Test2$/)
1212
- end
1213
- end
1214
- end
1215
- context 'when --stack-names Test3' do
1216
- before(:each) { run_command('cfndk stack report --stack-names Test3') }
1217
- it 'displays stacks report' do
1218
- aggregate_failures do
1219
- expect(last_command_started).to be_successfully_executed
1220
- expect(last_command_started).not_to have_output(/INFO stack: Test$/)
1221
- expect(last_command_started).not_to have_output(/INFO stack: Test2$/)
1222
- expect(last_command_started).not_to have_output(/INFO stack: Test3$/)
1223
- end
1224
- end
1225
- end
1226
- after(:each) { run_command('cfndk destroy -f') }
1227
- end
1228
- context 'with UUID' do
1229
- before(:each) { write_file('cfndk.yml', yaml) }
1230
- before(:each) { copy('%/vpc.yaml', 'vpc.yaml') }
1231
- before(:each) { copy('%/vpc.json', 'vpc.json') }
1232
- before(:each) { copy('%/sg.yaml', 'sg.yaml') }
1233
- before(:each) { copy('%/sg.json', 'sg.json') }
1234
- before(:each) { run_command_and_stop('cfndk create -u 38437346-c75c-47c5-83b4-d504f85e275b') }
1235
- context 'without option' do
1236
- before(:each) { run_command('cfndk stack report -u 38437346-c75c-47c5-83b4-d504f85e275b') }
1237
- it 'displays stacks report' do
1238
- aggregate_failures do
1239
- expect(last_command_started).to be_successfully_executed
1240
- expect(last_command_started).to have_output(/INFO stack: Test-38437346-c75c-47c5-83b4-d504f85e275b$/)
1241
- expect(last_command_started).to have_output(/INFO stack: Test2-38437346-c75c-47c5-83b4-d504f85e275b$/)
1242
- end
1243
- end
1244
- end
1245
- context 'when --stack-names Test2' do
1246
- before(:each) { run_command('cfndk stack report -u 38437346-c75c-47c5-83b4-d504f85e275b --stack-names Test2') }
1247
- it 'displays stacks report' do
1248
- aggregate_failures do
1249
- expect(last_command_started).to be_successfully_executed
1250
- expect(last_command_started).not_to have_output(/INFO stack: Test-38437346-c75c-47c5-83b4-d504f85e275b$/)
1251
- expect(last_command_started).to have_output(/INFO stack: Test2-38437346-c75c-47c5-83b4-d504f85e275b$/)
1252
- end
1253
- end
1254
- end
1255
- context 'when --stack-names Test3' do
1256
- before(:each) { run_command('cfndk stack report -u 38437346-c75c-47c5-83b4-d504f85e275b --stack-names Test3') }
1257
- it 'displays stacks report' do
1258
- aggregate_failures do
1259
- expect(last_command_started).to be_successfully_executed
1260
- expect(last_command_started).not_to have_output(/INFO stack: Test-/)
1261
- expect(last_command_started).not_to have_output(/INFO stack: Test2-/)
1262
- expect(last_command_started).not_to have_output(/INFO stack: Test3-/)
1263
- end
1264
- end
125
+ expect(last_command_started).to have_output(/ERROR Aws::CloudFormation::Errors::ValidationError: \[\/Resources\] 'null' values are not allowed in templates$/)
1265
126
  end
1266
- after(:each) { run_command('cfndk destroy -f -u 38437346-c75c-47c5-83b4-d504f85e275b') }
1267
127
  end
1268
128
  end
1269
129
  end