@@ -19,7 +19,7 @@ describe('CDK Include for nested stacks', () => {
19
19
test ( 'can ingest a template with one child' , ( ) => {
20
20
const parentTemplate = new inc . CfnInclude ( stack , 'ParentStack' , {
21
21
templateFile : testTemplateFilePath ( 'parent-one-child.json' ) ,
22
- nestedStacks : {
22
+ loadNestedStacks : {
23
23
'ChildStack' : {
24
24
templateFile : testTemplateFilePath ( 'grandchild-import-stack.json' ) ,
25
25
} ,
@@ -35,7 +35,7 @@ describe('CDK Include for nested stacks', () => {
35
35
test ( 'can ingest a template with two children' , ( ) => {
36
36
const parentTemplate = new inc . CfnInclude ( stack , 'ParentStack' , {
37
37
templateFile : testTemplateFilePath ( 'parent-two-children.json' ) ,
38
- nestedStacks : {
38
+ loadNestedStacks : {
39
39
'ChildStack' : {
40
40
templateFile : testTemplateFilePath ( 'grandchild-import-stack.json' ) ,
41
41
} ,
@@ -59,10 +59,10 @@ describe('CDK Include for nested stacks', () => {
59
59
test ( 'can ingest a template with one child and one grandchild' , ( ) => {
60
60
const parentTemplate = new inc . CfnInclude ( stack , 'ParentStack' , {
61
61
templateFile : testTemplateFilePath ( 'parent-two-children.json' ) ,
62
- nestedStacks : {
62
+ loadNestedStacks : {
63
63
'ChildStack' : {
64
64
templateFile : testTemplateFilePath ( 'child-import-stack.json' ) ,
65
- nestedStacks : {
65
+ loadNestedStacks : {
66
66
'GrandChildStack' : {
67
67
templateFile : testTemplateFilePath ( 'grandchild-import-stack.json' ) ,
68
68
} ,
@@ -86,7 +86,7 @@ describe('CDK Include for nested stacks', () => {
86
86
expect ( ( ) => {
87
87
new inc . CfnInclude ( stack , 'ParentStack' , {
88
88
templateFile : testTemplateFilePath ( 'parent-two-children.json' ) ,
89
- nestedStacks : {
89
+ loadNestedStacks : {
90
90
'FakeStack' : {
91
91
templateFile : testTemplateFilePath ( 'child-import-stack.json' ) ,
92
92
} ,
@@ -99,7 +99,7 @@ describe('CDK Include for nested stacks', () => {
99
99
expect ( ( ) => {
100
100
new inc . CfnInclude ( stack , 'ParentStack' , {
101
101
templateFile : testTemplateFilePath ( 'child-import-stack.json' ) ,
102
- nestedStacks : {
102
+ loadNestedStacks : {
103
103
'BucketImport' : {
104
104
templateFile : testTemplateFilePath ( 'grandchild-import-stack.json' ) ,
105
105
} ,
@@ -112,7 +112,7 @@ describe('CDK Include for nested stacks', () => {
112
112
expect ( ( ) => {
113
113
new inc . CfnInclude ( stack , 'ParentStack' , {
114
114
templateFile : testTemplateFilePath ( 'parent-creation-policy.json' ) ,
115
- nestedStacks : {
115
+ loadNestedStacks : {
116
116
'ChildStack' : {
117
117
templateFile : testTemplateFilePath ( 'grandchild-import-stack.json' ) ,
118
118
} ,
@@ -125,7 +125,7 @@ describe('CDK Include for nested stacks', () => {
125
125
expect ( ( ) => {
126
126
new inc . CfnInclude ( stack , 'ParentStack' , {
127
127
templateFile : testTemplateFilePath ( 'parent-update-policy.json' ) ,
128
- nestedStacks : {
128
+ loadNestedStacks : {
129
129
'ChildStack' : {
130
130
templateFile : testTemplateFilePath ( 'grandchild-import-stack.json' ) ,
131
131
} ,
@@ -138,7 +138,7 @@ describe('CDK Include for nested stacks', () => {
138
138
expect ( ( ) => {
139
139
new inc . CfnInclude ( stack , 'ParentStack' , {
140
140
templateFile : testTemplateFilePath ( 'parent-invalid-condition.json' ) ,
141
- nestedStacks : {
141
+ loadNestedStacks : {
142
142
'ChildStack' : {
143
143
templateFile : testTemplateFilePath ( 'grandchild-import-stack.json' ) ,
144
144
} ,
@@ -151,7 +151,7 @@ describe('CDK Include for nested stacks', () => {
151
151
expect ( ( ) => {
152
152
new inc . CfnInclude ( stack , 'ParentStack' , {
153
153
templateFile : testTemplateFilePath ( 'parent-bad-depends-on.json' ) ,
154
- nestedStacks : {
154
+ loadNestedStacks : {
155
155
'ChildStack' : {
156
156
templateFile : testTemplateFilePath ( 'child-import-stack.json' ) ,
157
157
} ,
@@ -160,11 +160,11 @@ describe('CDK Include for nested stacks', () => {
160
160
} ) . toThrow ( / R e s o u r c e ' C h i l d S t a c k ' d e p e n d s o n ' A F a k e R e s o u r c e ' t h a t d o e s n ' t e x i s t / ) ;
161
161
} ) ;
162
162
163
- test ( 'throws an exception when an ID was passed in nestedStacks that is a resource type not in the CloudFormation schema' , ( ) => {
163
+ test ( 'throws an exception when an ID was passed in loadNestedStacks that is a resource type not in the CloudFormation schema' , ( ) => {
164
164
expect ( ( ) => {
165
165
new inc . CfnInclude ( stack , 'Template' , {
166
166
templateFile : testTemplateFilePath ( 'custom-resource.json' ) ,
167
- nestedStacks : {
167
+ loadNestedStacks : {
168
168
'CustomResource' : {
169
169
templateFile : testTemplateFilePath ( 'whatever.json' ) ,
170
170
} ,
@@ -176,7 +176,7 @@ describe('CDK Include for nested stacks', () => {
176
176
test ( 'can modify resources in nested stacks' , ( ) => {
177
177
const parent = new inc . CfnInclude ( stack , 'ParentStack' , {
178
178
templateFile : testTemplateFilePath ( 'child-import-stack.json' ) ,
179
- nestedStacks : {
179
+ loadNestedStacks : {
180
180
'GrandChildStack' : {
181
181
templateFile : testTemplateFilePath ( 'grandchild-import-stack.json' ) ,
182
182
} ,
@@ -194,7 +194,7 @@ describe('CDK Include for nested stacks', () => {
194
194
test ( 'can use a condition' , ( ) => {
195
195
const parent = new inc . CfnInclude ( stack , 'ParentStack' , {
196
196
templateFile : testTemplateFilePath ( 'parent-valid-condition.json' ) ,
197
- nestedStacks : {
197
+ loadNestedStacks : {
198
198
'ChildStack' : {
199
199
templateFile : testTemplateFilePath ( 'grandchild-import-stack.json' ) ,
200
200
} ,
@@ -209,7 +209,7 @@ describe('CDK Include for nested stacks', () => {
209
209
test ( 'asset parameters generated in parent and child are identical' , ( ) => {
210
210
new inc . CfnInclude ( stack , 'ParentStack' , {
211
211
templateFile : testTemplateFilePath ( 'parent-one-child.json' ) ,
212
- nestedStacks : {
212
+ loadNestedStacks : {
213
213
'ChildStack' : {
214
214
templateFile : testTemplateFilePath ( 'grandchild-import-stack.json' ) ,
215
215
} ,
@@ -279,7 +279,7 @@ describe('CDK Include for nested stacks', () => {
279
279
} ) ;
280
280
} ) ;
281
281
282
- test ( 'templates with nested stacks that were not provided in the nestedStacks property are left unmodified' , ( ) => {
282
+ test ( 'templates with nested stacks that were not provided in the loadNestedStacks property are left unmodified' , ( ) => {
283
283
new inc . CfnInclude ( stack , 'ParentStack' , {
284
284
templateFile : testTemplateFilePath ( 'parent-two-children.json' ) ,
285
285
} ) ;
@@ -290,7 +290,7 @@ describe('CDK Include for nested stacks', () => {
290
290
test ( 'getNestedStack() throws an exception when getting a resource that does not exist in the template' , ( ) => {
291
291
const parentTemplate = new inc . CfnInclude ( stack , 'ParentStack' , {
292
292
templateFile : testTemplateFilePath ( 'parent-two-children.json' ) ,
293
- nestedStacks : {
293
+ loadNestedStacks : {
294
294
'ChildStack' : {
295
295
templateFile : testTemplateFilePath ( 'child-import-stack.json' ) ,
296
296
} ,
@@ -305,7 +305,7 @@ describe('CDK Include for nested stacks', () => {
305
305
test ( 'getNestedStack() throws an exception when getting a resource that exists in the template, but is not a Stack' , ( ) => {
306
306
const parentTemplate = new inc . CfnInclude ( stack , 'ParentStack' , {
307
307
templateFile : testTemplateFilePath ( 'parent-two-children.json' ) ,
308
- nestedStacks : {
308
+ loadNestedStacks : {
309
309
'ChildStack' : {
310
310
templateFile : testTemplateFilePath ( 'child-import-stack.json' ) ,
311
311
} ,
@@ -319,10 +319,10 @@ describe('CDK Include for nested stacks', () => {
319
319
} ) . toThrow ( / R e s o u r c e w i t h l o g i c a l I D ' B u c k e t I m p o r t ' i s n o t a C l o u d F o r m a t i o n S t a c k / ) ;
320
320
} ) ;
321
321
322
- test ( 'getNestedStack() throws an exception when getting a resource that exists in the template, but was not specified in the props' , ( ) => {
322
+ test ( 'getNestedStack() throws an exception when getting a nested stack that exists in the template, but was not specified in the props' , ( ) => {
323
323
const parentTemplate = new inc . CfnInclude ( stack , 'ParentStack' , {
324
324
templateFile : testTemplateFilePath ( 'parent-two-children.json' ) ,
325
- nestedStacks : {
325
+ loadNestedStacks : {
326
326
'ChildStack' : {
327
327
templateFile : testTemplateFilePath ( 'child-import-stack.json' ) ,
328
328
} ,
@@ -331,13 +331,13 @@ describe('CDK Include for nested stacks', () => {
331
331
332
332
expect ( ( ) => {
333
333
parentTemplate . getNestedStack ( 'AnotherChildStack' ) ;
334
- } ) . toThrow ( / N e s t e d S t a c k ' A n o t h e r C h i l d S t a c k ' w a s n o t i n c l u d e d i n t h e n e s t e d S t a c k s p r o p e r t y w h e n i n c l u d i n g t h e p a r e n t t e m p l a t e / ) ;
334
+ } ) . toThrow ( / N e s t e d S t a c k ' A n o t h e r C h i l d S t a c k ' w a s n o t i n c l u d e d i n t h e p a r e n t t e m p l a t e / ) ;
335
335
} ) ;
336
336
337
337
test ( 'correctly handles renaming of references across nested stacks' , ( ) => {
338
338
const parentTemplate = new inc . CfnInclude ( stack , 'ParentStack' , {
339
339
templateFile : testTemplateFilePath ( 'cross-stack-refs.json' ) ,
340
- nestedStacks : {
340
+ loadNestedStacks : {
341
341
'ChildStack' : {
342
342
templateFile : testTemplateFilePath ( 'child-import-stack.json' ) ,
343
343
} ,
@@ -360,7 +360,7 @@ describe('CDK Include for nested stacks', () => {
360
360
} ) ;
361
361
} ) ;
362
362
363
- test ( 'returns the CfnStack object from getResource() for a nested stack that was not in the nestedStacks property' , ( ) => {
363
+ test ( 'returns the CfnStack object from getResource() for a nested stack that was not in the loadNestedStacks property' , ( ) => {
364
364
const cfnTemplate = new inc . CfnInclude ( stack , 'ParentStack' , {
365
365
templateFile : testTemplateFilePath ( 'parent-two-children.json' ) ,
366
366
} ) ;
@@ -370,10 +370,10 @@ describe('CDK Include for nested stacks', () => {
370
370
expect ( childStack1 ) . toBeInstanceOf ( core . CfnStack ) ;
371
371
} ) ;
372
372
373
- test ( 'returns the CfnStack object from getResource() for a nested stack that was in the nestedStacks property' , ( ) => {
373
+ test ( 'returns the CfnStack object from getResource() for a nested stack that was in the loadNestedStacks property' , ( ) => {
374
374
const cfnTemplate = new inc . CfnInclude ( stack , 'ParentStack' , {
375
375
templateFile : testTemplateFilePath ( 'parent-one-child.json' ) ,
376
- nestedStacks : {
376
+ loadNestedStacks : {
377
377
'ChildStack' : {
378
378
templateFile : testTemplateFilePath ( 'child-import-stack.json' ) ,
379
379
} ,
@@ -388,7 +388,7 @@ describe('CDK Include for nested stacks', () => {
388
388
test ( "handles Metadata, DeletionPolicy, and UpdateReplacePolicy attributes of the nested stack's resource" , ( ) => {
389
389
const cfnTemplate = new inc . CfnInclude ( stack , 'ParentStack' , {
390
390
templateFile : testTemplateFilePath ( 'parent-with-attributes.json' ) ,
391
- nestedStacks : {
391
+ loadNestedStacks : {
392
392
'ChildStack' : {
393
393
templateFile : testTemplateFilePath ( 'child-import-stack.json' ) ,
394
394
} ,
@@ -424,6 +424,20 @@ describe('CDK Include for nested stacks', () => {
424
424
} ) ;
425
425
} ) ;
426
426
427
+ test ( 'can lazily include a single child nested stack' , ( ) => {
428
+ const parentTemplate = new inc . CfnInclude ( stack , 'ParentStack' , {
429
+ templateFile : testTemplateFilePath ( 'parent-one-child.json' ) ,
430
+ } ) ;
431
+ const includedChild = parentTemplate . loadNestedStack ( 'ChildStack' , {
432
+ templateFile : testTemplateFilePath ( 'child-no-bucket.json' ) ,
433
+ } ) ;
434
+
435
+ expect ( includedChild . stack ) . toMatchTemplate (
436
+ loadTestFileToJsObject ( 'child-no-bucket.json' ) ,
437
+ ) ;
438
+ expect ( includedChild . includedTemplate . getResource ( 'GrandChildStack' ) ) . toBeDefined ( ) ;
439
+ } ) ;
440
+
427
441
describe ( 'for a parent stack with children and grandchildren' , ( ) => {
428
442
let assetStack : core . Stack ;
429
443
let parentTemplate : inc . CfnInclude ;
@@ -442,10 +456,10 @@ describe('CDK Include for nested stacks', () => {
442
456
assetStack = new core . Stack ( ) ;
443
457
parentTemplate = new inc . CfnInclude ( assetStack , 'ParentStack' , {
444
458
templateFile : testTemplateFilePath ( 'parent-one-child.json' ) ,
445
- nestedStacks : {
459
+ loadNestedStacks : {
446
460
'ChildStack' : {
447
461
templateFile : testTemplateFilePath ( 'child-no-bucket.json' ) ,
448
- nestedStacks : {
462
+ loadNestedStacks : {
449
463
'GrandChildStack' : {
450
464
templateFile : testTemplateFilePath ( 'grandchild-import-stack.json' ) ,
451
465
} ,
@@ -621,7 +635,7 @@ describe('CDK Include for nested stacks', () => {
621
635
parentStack = new core . Stack ( ) ;
622
636
const parentTemplate = new inc . CfnInclude ( parentStack , 'ParentStack' , {
623
637
templateFile : testTemplateFilePath ( 'parent-two-parameters.json' ) ,
624
- nestedStacks : {
638
+ loadNestedStacks : {
625
639
'ChildStack' : {
626
640
templateFile : testTemplateFilePath ( 'child-two-parameters.json' ) ,
627
641
parameters : {
0 commit comments