@@ -520,6 +520,66 @@ describe('awsCompileCloudWatchEventEvents', () => {
520520 . FirstEventsRuleCloudWatchEvent1 . Properties . Targets [ 0 ] . Input ) . to . equal ( '{"key":"value"}' ) ;
521521 } ) ;
522522
523+ itParam ( 'should respect iamRole variable' , [ 'cloudwatchEvent' , 'eventBridge' ] , ( source ) => {
524+ serverlessStepFunctions . serverless . service . stepFunctions = {
525+ stateMachines : {
526+ first : {
527+ events : [
528+ {
529+ [ source ] : {
530+ event : {
531+ source : [ 'aws.ec2' ] ,
532+ 'detail-type' : [ 'EC2 Instance State-change Notification' ] ,
533+ detail : { state : [ 'pending' ] } ,
534+ } ,
535+ enabled : false ,
536+ input : '{"key":"value"}' ,
537+ name : 'test-event-name' ,
538+ iamRole : 'arn:aws:iam::012345678910:role/my-role' ,
539+ } ,
540+ } ,
541+ ] ,
542+ } ,
543+ } ,
544+ } ;
545+
546+ serverlessStepFunctions . compileCloudWatchEventEvents ( ) ;
547+
548+ expect ( serverlessStepFunctions . serverless . service
549+ . provider . compiledCloudFormationTemplate . Resources . FirstEventsRuleCloudWatchEvent1
550+ . Properties . Targets [ 0 ] . RoleArn ) . to . equal ( 'arn:aws:iam::012345678910:role/my-role' ) ;
551+ } ) ;
552+
553+ itParam ( 'should respect iamRole intrinsic function' , [ 'cloudwatchEvent' , 'eventBridge' ] , ( source ) => {
554+ serverlessStepFunctions . serverless . service . stepFunctions = {
555+ stateMachines : {
556+ first : {
557+ events : [
558+ {
559+ [ source ] : {
560+ event : {
561+ source : [ 'aws.ec2' ] ,
562+ 'detail-type' : [ 'EC2 Instance State-change Notification' ] ,
563+ detail : { state : [ 'pending' ] } ,
564+ } ,
565+ enabled : false ,
566+ input : '{"key":"value"}' ,
567+ name : 'test-event-name' ,
568+ iamRole : '{"Fn::GetAtt": ["StepFunctionsRole", "Arn"]}' ,
569+ } ,
570+ } ,
571+ ] ,
572+ } ,
573+ } ,
574+ } ;
575+
576+ serverlessStepFunctions . compileCloudWatchEventEvents ( ) ;
577+
578+ expect ( serverlessStepFunctions . serverless . service
579+ . provider . compiledCloudFormationTemplate . Resources . FirstEventsRuleCloudWatchEvent1
580+ . Properties . Targets [ 0 ] . RoleArn ) . to . equal ( '{"Fn::GetAtt": ["StepFunctionsRole", "Arn"]}' ) ;
581+ } ) ;
582+
523583 it ( 'should not create corresponding resources when events are not given' , ( ) => {
524584 serverlessStepFunctions . serverless . service . stepFunctions = {
525585 stateMachines : {
0 commit comments