@@ -1383,6 +1383,69 @@ describe('#compileIamRole', () => {
13831383    expect ( lambdaPermissions [ 0 ] . Resource ) . to . deep . include . members ( lambdaArns ) ; 
13841384  } ) ; 
13851385
1386+   it ( 'should support lambda ARNs as task resource with and without aliases' ,  ( )  =>  { 
1387+     const  getStateMachine  =  name  =>  ( { 
1388+       name, 
1389+       definition : { 
1390+         StartAt : 'A' , 
1391+         States : { 
1392+           A : { 
1393+             Type : 'Task' , 
1394+             Resource : 'arn:aws:lambda:region:accountId:function:with-alias:some-alias' , 
1395+             Next : 'B' , 
1396+           } , 
1397+           B : { 
1398+             Type : 'Task' , 
1399+             Resource : 'arn:aws:lambda:region:accountId:function:no-alias' , 
1400+             End : true , 
1401+           } , 
1402+         } , 
1403+       } , 
1404+     } ) ; 
1405+ 
1406+     serverless . service . functions  =  { 
1407+       'with-alias' : { 
1408+         handler : 'with-alias.handler' , 
1409+       } , 
1410+       'no-alias' : { 
1411+         handler : 'with-alias.handler' , 
1412+       } , 
1413+     } ; 
1414+ 
1415+     serverless . service . stepFunctions  =  { 
1416+       stateMachines : { 
1417+         myStateMachine1 : getStateMachine ( 'sm1' ) , 
1418+         myStateMachine2 : getStateMachine ( 'sm2' ) , 
1419+       } , 
1420+     } ; 
1421+ 
1422+     serverlessStepFunctions . compileIamRole ( ) ; 
1423+     const  statements  =  serverlessStepFunctions . serverless . service 
1424+       . provider . compiledCloudFormationTemplate . Resources . IamRoleStateMachineExecution 
1425+       . Properties . Policies [ 0 ] . PolicyDocument . Statement ; 
1426+ 
1427+     const  lambdaPermissions  =  statements . filter ( s  =>  _ . isEqual ( s . Action ,  [ 'lambda:InvokeFunction' ] ) ) ; 
1428+     expect ( lambdaPermissions ) . to . have . lengthOf ( 1 ) ; 
1429+ 
1430+     const  expectedResources  =  [ 
1431+       'arn:aws:lambda:region:accountId:function:with-alias' , 
1432+       { 
1433+         'Fn::Sub' : [ 
1434+           '${functionArn}:*' , 
1435+           {  functionArn : 'arn:aws:lambda:region:accountId:function:with-alias'  } , 
1436+         ] , 
1437+       } , 
1438+       'arn:aws:lambda:region:accountId:function:no-alias' , 
1439+       { 
1440+         'Fn::Sub' : [ 
1441+           '${functionArn}:*' , 
1442+           {  functionArn : 'arn:aws:lambda:region:accountId:function:no-alias'  } , 
1443+         ] , 
1444+       } , 
1445+     ] ; 
1446+     expect ( lambdaPermissions [ 0 ] . Resource ) . to . deep . include . members ( expectedResources ) ; 
1447+   } ) ; 
1448+ 
13861449  it ( 'should give step functions permissions (too permissive, but mirrors console behaviour)' ,  ( )  =>  { 
13871450    const  stateMachineArn  =  'arn:aws:states:us-east-1:123456789:stateMachine:HelloStateMachine' ; 
13881451    const  genStateMachine  =  name  =>  ( { 
0 commit comments