@@ -362,6 +362,56 @@ describe('#compileIamRole', () => {
362362 expect ( policy . PolicyDocument . Statement [ 0 ] . Resource ) . to . equal ( '*' ) ;
363363 } ) ;
364364
365+ it ( 'should give sqs:SendMessage permission to * whenever QueueUrl is some intrinsic function except Ref' , ( ) => {
366+ const helloQueue = 'https://sqs.#{AWS::Region}.amazonaws.com/#{AWS::AccountId}/hello' ;
367+ const worldQueue = 'https://sqs.us-east-1.amazonaws.com/#{AWS::AccountId}/world' ;
368+
369+ const genStateMachine = ( name , queueUrl ) => ( {
370+ name,
371+ definition : {
372+ StartAt : 'A' ,
373+ States : {
374+ A : {
375+ Type : 'Task' ,
376+ Resource : 'arn:aws:states:::sqs:sendMessage' ,
377+ Parameters : {
378+ QueueUrl : queueUrl ,
379+ Message : '42' ,
380+ } ,
381+ Next : 'B' ,
382+ } ,
383+ B : {
384+ Type : 'Task' ,
385+ Resource : 'arn:aws:states:::sqs:sendMessage' ,
386+ Parameters : {
387+ QueueUrl : {
388+ 'Fn::ImportValue' : 'some-shared-value-here' ,
389+ } ,
390+ Message : '42' ,
391+ } ,
392+ End : true ,
393+ } ,
394+ } ,
395+ } ,
396+ } ) ;
397+
398+ serverless . service . stepFunctions = {
399+ stateMachines : {
400+ myStateMachine1 : genStateMachine ( 'stateMachineBeta1' , helloQueue ) ,
401+ myStateMachine2 : genStateMachine ( 'stateMachineBeta2' , worldQueue ) ,
402+ } ,
403+ } ;
404+
405+ serverlessStepFunctions . compileIamRole ( ) ;
406+ const policy = serverlessStepFunctions . serverless . service
407+ . provider . compiledCloudFormationTemplate . Resources . IamRoleStateMachineExecution
408+ . Properties . Policies [ 0 ] ;
409+
410+ // when using instrinct functions other than Ref to define QueueUrl
411+ // we can't recontruct ARN from it, so we need to give broad permissions
412+ expect ( policy . PolicyDocument . Statement [ 0 ] . Resource ) . to . equal ( '*' ) ;
413+ } ) ;
414+
365415 it ( 'should not give sqs:SendMessage permission if QueueUrl and QueueUrl.$ are missing' , ( ) => {
366416 const genStateMachine = name => ( {
367417 name,
0 commit comments