File tree 2 files changed +39
-3
lines changed
2 files changed +39
-3
lines changed Original file line number Diff line number Diff line change @@ -362,7 +362,7 @@ function getRedshiftDataPermissions(action, state) {
362
362
function getLambdaPermissions ( state ) {
363
363
// function name can be name-only, name-only with alias, full arn or partial arn
364
364
// https://docs.aws.amazon.com/lambda/latest/dg/API_Invoke.html#API_Invoke_RequestParameters
365
- const functionName = state . Parameters . FunctionName ;
365
+ const functionName = getParameterOrArgument ( state , ' FunctionName' ) ;
366
366
if ( _ . isString ( functionName ) ) {
367
367
const segments = functionName . split ( ':' ) ;
368
368
@@ -429,10 +429,11 @@ function getLambdaPermissions(state) {
429
429
} ] ;
430
430
}
431
431
432
- if ( state . Parameters [ 'FunctionName.$' ] ) {
432
+ if ( getParameterOrArgument ( state , 'FunctionName.$' ) ) {
433
+ const allowedFunctions = getParameterOrArgument ( state , 'AllowedFunctions' ) ;
433
434
return [ {
434
435
action : 'lambda:InvokeFunction' ,
435
- resource : state . Parameters . AllowedFunctions ? state . Parameters . AllowedFunctions : '*' ,
436
+ resource : allowedFunctions || '*' ,
436
437
} ] ;
437
438
}
438
439
Original file line number Diff line number Diff line change @@ -3587,6 +3587,41 @@ describe('#compileIamRole', () => {
3587
3587
] ) ;
3588
3588
} ) ;
3589
3589
3590
+ it . only ( 'should resolve FunctionName from the Arguments property when there is no Parameters property' , ( ) => {
3591
+ serverless . service . stepFunctions = {
3592
+ stateMachines : {
3593
+ myStateMachine1 : {
3594
+ id : 'StateMachine1' ,
3595
+ definition : {
3596
+ StartAt : 'A' ,
3597
+ States : {
3598
+ A : {
3599
+ Type : 'Task' ,
3600
+ Resource : 'arn:aws:states:::lambda:invoke' ,
3601
+ Arguments : {
3602
+ FunctionName : 'arn:aws:lambda:us-west-2:1234567890:function:foo' ,
3603
+ Payload : '{% $states.input.Payload %}' ,
3604
+ } ,
3605
+ End : true ,
3606
+ } ,
3607
+ } ,
3608
+ } ,
3609
+ } ,
3610
+ } ,
3611
+ } ;
3612
+
3613
+ serverlessStepFunctions . compileIamRole ( ) ;
3614
+ const statements = serverlessStepFunctions . serverless . service
3615
+ . provider . compiledCloudFormationTemplate . Resources . StateMachine1Role
3616
+ . Properties . Policies [ 0 ] . PolicyDocument . Statement ;
3617
+ const lambdaPermissions = statements . filter ( s => _ . isEqual ( s . Action , [ 'lambda:InvokeFunction' ] ) ) ;
3618
+ expect ( lambdaPermissions ) . to . have . lengthOf ( 1 ) ;
3619
+ expect ( lambdaPermissions [ 0 ] . Resource ) . to . deep . equal ( [
3620
+ 'arn:aws:lambda:us-west-2:1234567890:function:foo' ,
3621
+ 'arn:aws:lambda:us-west-2:1234567890:function:foo:*' ,
3622
+ ] ) ;
3623
+ } ) ;
3624
+
3590
3625
it ( 'should support variable FunctionName' , ( ) => {
3591
3626
serverless . service . stepFunctions = {
3592
3627
stateMachines : {
You can’t perform that action at this time.
0 commit comments