@@ -3721,6 +3721,60 @@ describe('#compileIamRole', () => {
37213721 } ,
37223722 ] ) ;
37233723 } ) ;
3724+
3725+ it ( 'should give event bridge scheduler createSchedule permissions' , ( ) => {
3726+ const genStateMachine = id => ( {
3727+ id,
3728+ definition : {
3729+ StartAt : 'A' ,
3730+ States : {
3731+ A : {
3732+ Type : 'Task' ,
3733+ Resource : 'arn:aws:states:::aws-sdk:scheduler:createSchedule' ,
3734+ Parameters : {
3735+ ActionAfterCompletion : 'DELETE' ,
3736+ FlexibleTimeWindow : {
3737+ Mode : 'FLEXIBLE' ,
3738+ MaximumWindowInMinutes : 5 ,
3739+ } ,
3740+ 'Name.$' : '$$.Execution.Name' ,
3741+ GroupName : 'MyScheduleGroup' ,
3742+ ScheduleExpression : 'at("2024-03-04T00:00:00")' ,
3743+ Target : {
3744+ Arn : 'arn:aws:states:${AWS::Region}:${AWS::AccountId}:stateMachine:MyStateMachine' ,
3745+ RoleArn : 'arn:aws:iam::${AWS::AccountId}:role/MyIAMRole' ,
3746+ Input : {
3747+ foo : 'bar' ,
3748+ } ,
3749+ } ,
3750+ } ,
3751+ End : true ,
3752+ } ,
3753+ } ,
3754+ } ,
3755+ } ) ;
3756+
3757+ serverless . service . stepFunctions = {
3758+ stateMachines : {
3759+ myStateMachine1 : genStateMachine ( 'StateMachine1' ) ,
3760+ } ,
3761+ } ;
3762+
3763+ serverlessStepFunctions . compileIamRole ( ) ;
3764+ const statements = serverlessStepFunctions . serverless . service
3765+ . provider . compiledCloudFormationTemplate . Resources . StateMachine1Role
3766+ . Properties . Policies [ 0 ] . PolicyDocument . Statement ;
3767+
3768+ const eventPermissions = statements . filter ( s => _ . isEqual ( s . Action , [ 'scheduler:CreateSchedule' ] ) ) ;
3769+ expect ( eventPermissions [ 0 ] . Resource ) . to . has . lengthOf ( 1 ) ;
3770+ expect ( eventPermissions [ 0 ] . Resource ) . to . deep . eq ( [ {
3771+ 'Fn::Sub' : [
3772+ 'arn:${AWS::Partition}:scheduler:${AWS::Region}:${AWS::AccountId}:schedule/${scheduleGroupName}/*' ,
3773+ { scheduleGroupName : 'MyScheduleGroup' } ,
3774+ ] ,
3775+ } ] ) ;
3776+ } ) ;
3777+
37243778 it ( 'should handle permissionsBoundary' , ( ) => {
37253779 serverless . service . stepFunctions = {
37263780 stateMachines : {
0 commit comments