@@ -3629,7 +3629,7 @@ describe('#compileIamRole', () => {
3629
3629
] ) ;
3630
3630
} ) ;
3631
3631
3632
- it ( 'should support variable FunctionName' , ( ) => {
3632
+ itParam ( 'should support variable FunctionName: ${value} ' , [ 'JSONPath' , 'JSONata' ] , ( queryLanguage ) => {
3633
3633
serverless . service . stepFunctions = {
3634
3634
stateMachines : {
3635
3635
myStateMachine1 : {
@@ -3640,26 +3640,47 @@ describe('#compileIamRole', () => {
3640
3640
A : {
3641
3641
Type : 'Task' ,
3642
3642
Resource : 'arn:aws:states:::lambda:invoke.waitForTaskToken' ,
3643
- Parameters : {
3644
- 'FunctionName.$' : '$.functionName' ,
3645
- Payload : {
3646
- 'model.$' : '$.new_model' ,
3647
- 'token.$' : '$$.Task.Token' ,
3643
+ ...getParamsOrArgs (
3644
+ queryLanguage ,
3645
+ {
3646
+ 'FunctionName.$' : '$.functionName' ,
3647
+ Payload : {
3648
+ 'model.$' : '$.new_model' ,
3649
+ 'token.$' : '$$.Task.Token' ,
3650
+ } ,
3648
3651
} ,
3649
- } ,
3652
+ {
3653
+ FunctionName : '{% $states.input.functionName %}' ,
3654
+ Payload : {
3655
+ model : '{% $states.input.new_model %}' ,
3656
+ token : '{% $states.context.Task.Token %}' ,
3657
+ } ,
3658
+ } ,
3659
+ ) ,
3650
3660
Next : 'B' ,
3651
3661
} ,
3652
3662
B : {
3653
3663
Type : 'Task' ,
3654
3664
Resource : 'arn:aws:states:::lambda:invoke.waitForTaskToken' ,
3655
- Parameters : {
3656
- 'FunctionName.$' : '$.functionName' ,
3657
- AllowedFunctions : '*limited*' ,
3658
- Payload : {
3659
- 'model.$' : '$.new_model' ,
3660
- 'token.$' : '$$.Task.Token' ,
3665
+ ...getParamsOrArgs (
3666
+ queryLanguage ,
3667
+ {
3668
+ 'FunctionName.$' : '$.functionName' ,
3669
+ AllowedFunctions : '*limited*' ,
3670
+ Payload : {
3671
+ 'model.$' : '$.new_model' ,
3672
+ 'token.$' : '$$.Task.Token' ,
3673
+ } ,
3661
3674
} ,
3662
- } ,
3675
+ {
3676
+ FunctionName : '{% $states.input.functionName %}' ,
3677
+ AllowedFunctions : '*limited*' ,
3678
+ Payload : {
3679
+ model : '{% $states.input.new_model %}' ,
3680
+ token : '{% $states.context.Task.Token %}' ,
3681
+ } ,
3682
+ } ,
3683
+ ) ,
3663
3684
End : true ,
3664
3685
} ,
3665
3686
} ,
@@ -3685,27 +3706,49 @@ describe('#compileIamRole', () => {
3685
3706
A : {
3686
3707
Type : 'Task' ,
3687
3708
Resource : 'arn:aws:states:::lambda:invoke.waitForTaskToken' ,
3688
- Parameters : {
3689
- 'FunctionName.$' : '$.functionName' ,
3690
- AllowedFunctions : 'arn:aws:lambda:us-west-2:1234567890:function:foo' ,
3691
- Payload : {
3692
- 'model.$' : '$.new_model' ,
3693
- 'token.$' : '$$.Task.Token' ,
3709
+ ...getParamsOrArgs (
3710
+ queryLanguage ,
3711
+ {
3712
+ 'FunctionName.$' : '$.functionName' ,
3713
+ AllowedFunctions : 'arn:aws:lambda:us-west-2:1234567890:function:foo' ,
3714
+ Payload : {
3715
+ 'model.$' : '$.new_model' ,
3716
+ 'token.$' : '$$.Task.Token' ,
3717
+ } ,
3694
3718
} ,
3695
- } ,
3719
+ {
3720
+ FunctionName : '{% $states.input.functionName %}' ,
3721
+ AllowedFunctions : 'arn:aws:lambda:us-west-2:1234567890:function:foo' ,
3722
+ Payload : {
3723
+ model : '{% $states.input.new_model %}' ,
3724
+ token : '{% $states.context.Task.Token %}' ,
3725
+ } ,
3726
+ } ,
3727
+ ) ,
3696
3728
Next : 'B' ,
3697
3729
} ,
3698
3730
B : {
3699
3731
Type : 'Task' ,
3700
3732
Resource : 'arn:aws:states:::lambda:invoke.waitForTaskToken' ,
3701
- Parameters : {
3702
- 'FunctionName.$' : '$.functionName' ,
3703
- AllowedFunctions : '*limited*' ,
3704
- Payload : {
3705
- 'model.$' : '$.new_model' ,
3706
- 'token.$' : '$$.Task.Token' ,
3733
+ ...getParamsOrArgs (
3734
+ queryLanguage ,
3735
+ {
3736
+ 'FunctionName.$' : '$.functionName' ,
3737
+ AllowedFunctions : '*limited*' ,
3738
+ Payload : {
3739
+ 'model.$' : '$.new_model' ,
3740
+ 'token.$' : '$$.Task.Token' ,
3741
+ } ,
3707
3742
} ,
3708
- } ,
3743
+ {
3744
+ FunctionName : '{% $states.input.functionName %}' ,
3745
+ AllowedFunctions : '*limited*' ,
3746
+ Payload : {
3747
+ model : '{% $states.input.new_model %}' ,
3748
+ token : '{% $states.context.Task.Token %}' ,
3749
+ } ,
3750
+ } ,
3751
+ ) ,
3709
3752
End : true ,
3710
3753
} ,
3711
3754
} ,
0 commit comments