@@ -59,10 +59,16 @@ void describe('AmplifyFunctionFactory', () => {
5959 assert . strictEqual ( instance1 , instance2 ) ;
6060 } ) ;
6161
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+
6268 void it ( 'resolves default name and entry when no args specified' , ( ) => {
6369 const functionFactory = defaultLambda ;
6470 const lambda = functionFactory . getInstance ( getInstanceProps ) ;
65- const template = Template . fromStack ( Stack . of ( lambda . resources . lambda ) ) ;
71+ const template = Template . fromStack ( lambda . stack ) ;
6672 template . resourceCountIs ( 'AWS::Lambda::Function' , 1 ) ;
6773 template . hasResourceProperties ( 'AWS::Lambda::Function' , {
6874 Handler : 'index.handler' ,
@@ -79,7 +85,7 @@ void describe('AmplifyFunctionFactory', () => {
7985 entry : './test-assets/default-lambda/handler.ts' ,
8086 } ) ;
8187 const lambda = functionFactory . getInstance ( getInstanceProps ) ;
82- const template = Template . fromStack ( Stack . of ( lambda . resources . lambda ) ) ;
88+ const template = Template . fromStack ( lambda . stack ) ;
8389 template . resourceCountIs ( 'AWS::Lambda::Function' , 1 ) ;
8490 template . hasResourceProperties ( 'AWS::Lambda::Function' , {
8591 Handler : 'index.handler' ,
@@ -96,7 +102,7 @@ void describe('AmplifyFunctionFactory', () => {
96102 name : 'myCoolLambda' ,
97103 } ) ;
98104 const lambda = functionFactory . getInstance ( getInstanceProps ) ;
99- const template = Template . fromStack ( Stack . of ( lambda . resources . lambda ) ) ;
105+ const template = Template . fromStack ( lambda . stack ) ;
100106 template . resourceCountIs ( 'AWS::Lambda::Function' , 1 ) ;
101107 template . hasResourceProperties ( 'AWS::Lambda::Function' , {
102108 Handler : 'index.handler' ,
@@ -113,7 +119,7 @@ void describe('AmplifyFunctionFactory', () => {
113119 name : 'myCoolLambda' ,
114120 } ) ;
115121 const lambda = functionFactory . getInstance ( getInstanceProps ) ;
116- const template = Template . fromStack ( Stack . of ( lambda . resources . lambda ) ) ;
122+ const template = Template . fromStack ( lambda . stack ) ;
117123 template . resourceCountIs ( 'AWS::Lambda::Function' , 1 ) ;
118124 template . hasResourceProperties ( 'AWS::Lambda::Function' , {
119125 Tags : [ { Key : 'amplify:friendly-name' , Value : 'myCoolLambda' } ] ,
@@ -137,7 +143,7 @@ void describe('AmplifyFunctionFactory', () => {
137143
138144 void it ( 'builds lambda with local and 3p dependencies' , ( ) => {
139145 const lambda = lambdaWithDependencies . getInstance ( getInstanceProps ) ;
140- const template = Template . fromStack ( Stack . of ( lambda . resources . lambda ) ) ;
146+ const template = Template . fromStack ( lambda . stack ) ;
141147 // There isn't a way to check the contents of the bundled lambda using the CDK Template utility
142148 // So we just check that the lambda was created properly in the CFN template.
143149 // There is an e2e test that validates proper lambda bundling
@@ -159,7 +165,7 @@ void describe('AmplifyFunctionFactory', () => {
159165 } ) ;
160166 const lambda = functionFactory . getInstance ( getInstanceProps ) ;
161167 lambda . addEnvironment ( 'key1' , 'value1' ) ;
162- const stack = Stack . of ( lambda . resources . lambda ) ;
168+ const stack = lambda . stack ;
163169 const template = Template . fromStack ( stack ) ;
164170 template . resourceCountIs ( 'AWS::Lambda::Function' , 1 ) ;
165171 template . hasResourceProperties ( 'AWS::Lambda::Function' , {
@@ -177,7 +183,7 @@ void describe('AmplifyFunctionFactory', () => {
177183 entry : './test-assets/default-lambda/handler.ts' ,
178184 timeoutSeconds : 10 ,
179185 } ) . getInstance ( getInstanceProps ) ;
180- const template = Template . fromStack ( Stack . of ( lambda . resources . lambda ) ) ;
186+ const template = Template . fromStack ( lambda . stack ) ;
181187
182188 template . hasResourceProperties ( 'AWS::Lambda::Function' , {
183189 Timeout : 10 ,
@@ -230,7 +236,7 @@ void describe('AmplifyFunctionFactory', () => {
230236 entry : './test-assets/default-lambda/handler.ts' ,
231237 memoryMB : 234 ,
232238 } ) . getInstance ( getInstanceProps ) ;
233- const template = Template . fromStack ( Stack . of ( lambda . resources . lambda ) ) ;
239+ const template = Template . fromStack ( lambda . stack ) ;
234240
235241 template . hasResourceProperties ( 'AWS::Lambda::Function' , {
236242 MemorySize : 234 ,
@@ -241,7 +247,7 @@ void describe('AmplifyFunctionFactory', () => {
241247 const lambda = defineFunction ( {
242248 entry : './test-assets/default-lambda/handler.ts' ,
243249 } ) . getInstance ( getInstanceProps ) ;
244- const template = Template . fromStack ( Stack . of ( lambda . resources . lambda ) ) ;
250+ const template = Template . fromStack ( lambda . stack ) ;
245251
246252 template . hasResourceProperties ( 'AWS::Lambda::Function' , {
247253 MemorySize : 512 ,
@@ -294,7 +300,7 @@ void describe('AmplifyFunctionFactory', () => {
294300 entry : './test-assets/default-lambda/handler.ts' ,
295301 runtime : 16 ,
296302 } ) . getInstance ( getInstanceProps ) ;
297- const template = Template . fromStack ( Stack . of ( lambda . resources . lambda ) ) ;
303+ const template = Template . fromStack ( lambda . stack ) ;
298304
299305 template . hasResourceProperties ( 'AWS::Lambda::Function' , {
300306 Runtime : Runtime . NODEJS_16_X . name ,
@@ -305,7 +311,7 @@ void describe('AmplifyFunctionFactory', () => {
305311 const lambda = defineFunction ( {
306312 entry : './test-assets/default-lambda/handler.ts' ,
307313 } ) . getInstance ( getInstanceProps ) ;
308- const template = Template . fromStack ( Stack . of ( lambda . resources . lambda ) ) ;
314+ const template = Template . fromStack ( lambda . stack ) ;
309315
310316 template . hasResourceProperties ( 'AWS::Lambda::Function' , {
311317 Runtime : Runtime . NODEJS_18_X . name ,
@@ -340,7 +346,7 @@ void describe('AmplifyFunctionFactory', () => {
340346 entry : './test-assets/default-lambda/handler.ts' ,
341347 schedule : 'every 5m' ,
342348 } ) . getInstance ( getInstanceProps ) ;
343- const template = Template . fromStack ( Stack . of ( lambda . resources . lambda ) ) ;
349+ const template = Template . fromStack ( lambda . stack ) ;
344350
345351 template . hasResourceProperties ( 'AWS::Events::Rule' , {
346352 ScheduleExpression : 'cron(*/5 * * * ? *)' ,
@@ -361,7 +367,7 @@ void describe('AmplifyFunctionFactory', () => {
361367 entry : './test-assets/default-lambda/handler.ts' ,
362368 schedule : '0 1 * * ?' ,
363369 } ) . getInstance ( getInstanceProps ) ;
364- const template = Template . fromStack ( Stack . of ( lambda . resources . lambda ) ) ;
370+ const template = Template . fromStack ( lambda . stack ) ;
365371
366372 template . hasResourceProperties ( 'AWS::Events::Rule' , {
367373 ScheduleExpression : 'cron(0 1 * * ? *)' ,
@@ -382,7 +388,7 @@ void describe('AmplifyFunctionFactory', () => {
382388 entry : './test-assets/default-lambda/handler.ts' ,
383389 schedule : [ '0 1 * * ?' , 'every 5m' ] ,
384390 } ) . getInstance ( getInstanceProps ) ;
385- const template = Template . fromStack ( Stack . of ( lambda . resources . lambda ) ) ;
391+ const template = Template . fromStack ( lambda . stack ) ;
386392
387393 template . resourceCountIs ( 'AWS::Events::Rule' , 2 ) ;
388394
@@ -399,7 +405,7 @@ void describe('AmplifyFunctionFactory', () => {
399405 const lambda = defineFunction ( {
400406 entry : './test-assets/default-lambda/handler.ts' ,
401407 } ) . getInstance ( getInstanceProps ) ;
402- const template = Template . fromStack ( Stack . of ( lambda . resources . lambda ) ) ;
408+ const template = Template . fromStack ( lambda . stack ) ;
403409
404410 template . resourceCountIs ( 'AWS::Events::Rule' , 0 ) ;
405411 } ) ;
@@ -412,7 +418,7 @@ void describe('AmplifyFunctionFactory', () => {
412418 name : 'myCoolLambda' ,
413419 } ) ;
414420 const lambda = functionFactory . getInstance ( getInstanceProps ) ;
415- const stack = Stack . of ( lambda . resources . lambda ) ;
421+ const stack = lambda . stack ;
416422 const policy = new Policy ( stack , 'testPolicy' , {
417423 statements : [
418424 new PolicyStatement ( {
@@ -503,9 +509,7 @@ void describe('AmplifyFunctionFactory', () => {
503509 entry : './test-assets/default-lambda/handler.ts' ,
504510 name : 'anotherName' ,
505511 } ) ;
506- const functionStack = Stack . of (
507- functionFactory . getInstance ( getInstanceProps ) . resources . lambda
508- ) ;
512+ const functionStack = functionFactory . getInstance ( getInstanceProps ) . stack ;
509513 anotherFunction . getInstance ( getInstanceProps ) ;
510514 const template = Template . fromStack ( functionStack ) ;
511515 assert . equal (
0 commit comments