@@ -59,10 +59,16 @@ void describe('AmplifyFunctionFactory', () => {
59
59
assert . strictEqual ( instance1 , instance2 ) ;
60
60
} ) ;
61
61
62
+ void it ( 'verifies stack property exists and is equal to function stack' , ( ) => {
63
+ const functionFactory = defaultLambda ;
64
+ const lambda = functionFactory . getInstance ( getInstanceProps ) ;
65
+ assert . equal ( lambda . stack , Stack . of ( lambda . resources . lambda ) ) ;
66
+ } ) ;
67
+
62
68
void it ( 'resolves default name and entry when no args specified' , ( ) => {
63
69
const functionFactory = defaultLambda ;
64
70
const lambda = functionFactory . getInstance ( getInstanceProps ) ;
65
- const template = Template . fromStack ( Stack . of ( lambda . resources . lambda ) ) ;
71
+ const template = Template . fromStack ( lambda . stack ) ;
66
72
template . resourceCountIs ( 'AWS::Lambda::Function' , 1 ) ;
67
73
template . hasResourceProperties ( 'AWS::Lambda::Function' , {
68
74
Handler : 'index.handler' ,
@@ -79,7 +85,7 @@ void describe('AmplifyFunctionFactory', () => {
79
85
entry : './test-assets/default-lambda/handler.ts' ,
80
86
} ) ;
81
87
const lambda = functionFactory . getInstance ( getInstanceProps ) ;
82
- const template = Template . fromStack ( Stack . of ( lambda . resources . lambda ) ) ;
88
+ const template = Template . fromStack ( lambda . stack ) ;
83
89
template . resourceCountIs ( 'AWS::Lambda::Function' , 1 ) ;
84
90
template . hasResourceProperties ( 'AWS::Lambda::Function' , {
85
91
Handler : 'index.handler' ,
@@ -96,7 +102,7 @@ void describe('AmplifyFunctionFactory', () => {
96
102
name : 'myCoolLambda' ,
97
103
} ) ;
98
104
const lambda = functionFactory . getInstance ( getInstanceProps ) ;
99
- const template = Template . fromStack ( Stack . of ( lambda . resources . lambda ) ) ;
105
+ const template = Template . fromStack ( lambda . stack ) ;
100
106
template . resourceCountIs ( 'AWS::Lambda::Function' , 1 ) ;
101
107
template . hasResourceProperties ( 'AWS::Lambda::Function' , {
102
108
Handler : 'index.handler' ,
@@ -113,7 +119,7 @@ void describe('AmplifyFunctionFactory', () => {
113
119
name : 'myCoolLambda' ,
114
120
} ) ;
115
121
const lambda = functionFactory . getInstance ( getInstanceProps ) ;
116
- const template = Template . fromStack ( Stack . of ( lambda . resources . lambda ) ) ;
122
+ const template = Template . fromStack ( lambda . stack ) ;
117
123
template . resourceCountIs ( 'AWS::Lambda::Function' , 1 ) ;
118
124
template . hasResourceProperties ( 'AWS::Lambda::Function' , {
119
125
Tags : [ { Key : 'amplify:friendly-name' , Value : 'myCoolLambda' } ] ,
@@ -137,7 +143,7 @@ void describe('AmplifyFunctionFactory', () => {
137
143
138
144
void it ( 'builds lambda with local and 3p dependencies' , ( ) => {
139
145
const lambda = lambdaWithDependencies . getInstance ( getInstanceProps ) ;
140
- const template = Template . fromStack ( Stack . of ( lambda . resources . lambda ) ) ;
146
+ const template = Template . fromStack ( lambda . stack ) ;
141
147
// There isn't a way to check the contents of the bundled lambda using the CDK Template utility
142
148
// So we just check that the lambda was created properly in the CFN template.
143
149
// There is an e2e test that validates proper lambda bundling
@@ -159,7 +165,7 @@ void describe('AmplifyFunctionFactory', () => {
159
165
} ) ;
160
166
const lambda = functionFactory . getInstance ( getInstanceProps ) ;
161
167
lambda . addEnvironment ( 'key1' , 'value1' ) ;
162
- const stack = Stack . of ( lambda . resources . lambda ) ;
168
+ const stack = lambda . stack ;
163
169
const template = Template . fromStack ( stack ) ;
164
170
template . resourceCountIs ( 'AWS::Lambda::Function' , 1 ) ;
165
171
template . hasResourceProperties ( 'AWS::Lambda::Function' , {
@@ -177,7 +183,7 @@ void describe('AmplifyFunctionFactory', () => {
177
183
entry : './test-assets/default-lambda/handler.ts' ,
178
184
timeoutSeconds : 10 ,
179
185
} ) . getInstance ( getInstanceProps ) ;
180
- const template = Template . fromStack ( Stack . of ( lambda . resources . lambda ) ) ;
186
+ const template = Template . fromStack ( lambda . stack ) ;
181
187
182
188
template . hasResourceProperties ( 'AWS::Lambda::Function' , {
183
189
Timeout : 10 ,
@@ -230,7 +236,7 @@ void describe('AmplifyFunctionFactory', () => {
230
236
entry : './test-assets/default-lambda/handler.ts' ,
231
237
memoryMB : 234 ,
232
238
} ) . getInstance ( getInstanceProps ) ;
233
- const template = Template . fromStack ( Stack . of ( lambda . resources . lambda ) ) ;
239
+ const template = Template . fromStack ( lambda . stack ) ;
234
240
235
241
template . hasResourceProperties ( 'AWS::Lambda::Function' , {
236
242
MemorySize : 234 ,
@@ -241,7 +247,7 @@ void describe('AmplifyFunctionFactory', () => {
241
247
const lambda = defineFunction ( {
242
248
entry : './test-assets/default-lambda/handler.ts' ,
243
249
} ) . getInstance ( getInstanceProps ) ;
244
- const template = Template . fromStack ( Stack . of ( lambda . resources . lambda ) ) ;
250
+ const template = Template . fromStack ( lambda . stack ) ;
245
251
246
252
template . hasResourceProperties ( 'AWS::Lambda::Function' , {
247
253
MemorySize : 512 ,
@@ -294,7 +300,7 @@ void describe('AmplifyFunctionFactory', () => {
294
300
entry : './test-assets/default-lambda/handler.ts' ,
295
301
runtime : 16 ,
296
302
} ) . getInstance ( getInstanceProps ) ;
297
- const template = Template . fromStack ( Stack . of ( lambda . resources . lambda ) ) ;
303
+ const template = Template . fromStack ( lambda . stack ) ;
298
304
299
305
template . hasResourceProperties ( 'AWS::Lambda::Function' , {
300
306
Runtime : Runtime . NODEJS_16_X . name ,
@@ -305,7 +311,7 @@ void describe('AmplifyFunctionFactory', () => {
305
311
const lambda = defineFunction ( {
306
312
entry : './test-assets/default-lambda/handler.ts' ,
307
313
} ) . getInstance ( getInstanceProps ) ;
308
- const template = Template . fromStack ( Stack . of ( lambda . resources . lambda ) ) ;
314
+ const template = Template . fromStack ( lambda . stack ) ;
309
315
310
316
template . hasResourceProperties ( 'AWS::Lambda::Function' , {
311
317
Runtime : Runtime . NODEJS_18_X . name ,
@@ -340,7 +346,7 @@ void describe('AmplifyFunctionFactory', () => {
340
346
entry : './test-assets/default-lambda/handler.ts' ,
341
347
schedule : 'every 5m' ,
342
348
} ) . getInstance ( getInstanceProps ) ;
343
- const template = Template . fromStack ( Stack . of ( lambda . resources . lambda ) ) ;
349
+ const template = Template . fromStack ( lambda . stack ) ;
344
350
345
351
template . hasResourceProperties ( 'AWS::Events::Rule' , {
346
352
ScheduleExpression : 'cron(*/5 * * * ? *)' ,
@@ -361,7 +367,7 @@ void describe('AmplifyFunctionFactory', () => {
361
367
entry : './test-assets/default-lambda/handler.ts' ,
362
368
schedule : '0 1 * * ?' ,
363
369
} ) . getInstance ( getInstanceProps ) ;
364
- const template = Template . fromStack ( Stack . of ( lambda . resources . lambda ) ) ;
370
+ const template = Template . fromStack ( lambda . stack ) ;
365
371
366
372
template . hasResourceProperties ( 'AWS::Events::Rule' , {
367
373
ScheduleExpression : 'cron(0 1 * * ? *)' ,
@@ -382,7 +388,7 @@ void describe('AmplifyFunctionFactory', () => {
382
388
entry : './test-assets/default-lambda/handler.ts' ,
383
389
schedule : [ '0 1 * * ?' , 'every 5m' ] ,
384
390
} ) . getInstance ( getInstanceProps ) ;
385
- const template = Template . fromStack ( Stack . of ( lambda . resources . lambda ) ) ;
391
+ const template = Template . fromStack ( lambda . stack ) ;
386
392
387
393
template . resourceCountIs ( 'AWS::Events::Rule' , 2 ) ;
388
394
@@ -399,7 +405,7 @@ void describe('AmplifyFunctionFactory', () => {
399
405
const lambda = defineFunction ( {
400
406
entry : './test-assets/default-lambda/handler.ts' ,
401
407
} ) . getInstance ( getInstanceProps ) ;
402
- const template = Template . fromStack ( Stack . of ( lambda . resources . lambda ) ) ;
408
+ const template = Template . fromStack ( lambda . stack ) ;
403
409
404
410
template . resourceCountIs ( 'AWS::Events::Rule' , 0 ) ;
405
411
} ) ;
@@ -412,7 +418,7 @@ void describe('AmplifyFunctionFactory', () => {
412
418
name : 'myCoolLambda' ,
413
419
} ) ;
414
420
const lambda = functionFactory . getInstance ( getInstanceProps ) ;
415
- const stack = Stack . of ( lambda . resources . lambda ) ;
421
+ const stack = lambda . stack ;
416
422
const policy = new Policy ( stack , 'testPolicy' , {
417
423
statements : [
418
424
new PolicyStatement ( {
@@ -503,9 +509,7 @@ void describe('AmplifyFunctionFactory', () => {
503
509
entry : './test-assets/default-lambda/handler.ts' ,
504
510
name : 'anotherName' ,
505
511
} ) ;
506
- const functionStack = Stack . of (
507
- functionFactory . getInstance ( getInstanceProps ) . resources . lambda
508
- ) ;
512
+ const functionStack = functionFactory . getInstance ( getInstanceProps ) . stack ;
509
513
anotherFunction . getInstance ( getInstanceProps ) ;
510
514
const template = Template . fromStack ( functionStack ) ;
511
515
assert . equal (
0 commit comments