@@ -347,6 +347,59 @@ describe('#addCustomResourceToService()', () => {
347347 Resources . CustomDashresourceDashexistingDashs3LambdaFunction . Properties . FunctionName . length
348348 ) . to . be . below ( 65 ) ;
349349 } ) ;
350+
351+ it ( 'should use defined runtime' , async ( ) => {
352+ serverless . service . provider . runtime = 'nodejs22.x' ;
353+ await Promise . all ( [
354+ // add the custom S3 resource
355+ addCustomResourceToService ( provider , 's3' , [
356+ ...iamRoleStatements ,
357+ {
358+ Effect : 'Allow' ,
359+ Resource : 'arn:aws:s3:::some-bucket' ,
360+ Action : [ 's3:PutBucketNotification' , 's3:GetBucketNotification' ] ,
361+ } ,
362+ ] ) ,
363+ // add the custom Cognito User Pool resource
364+ addCustomResourceToService ( provider , 'cognitoUserPool' , [
365+ ...iamRoleStatements ,
366+ {
367+ Effect : 'Allow' ,
368+ Resource : '*' ,
369+ Action : [
370+ 'cognito-idp:ListUserPools' ,
371+ 'cognito-idp:DescribeUserPool' ,
372+ 'cognito-idp:UpdateUserPool' ,
373+ ] ,
374+ } ,
375+ ] ) ,
376+ // add the custom Event Bridge resource
377+ addCustomResourceToService ( provider , 'eventBridge' , [
378+ ...iamRoleStatements ,
379+ {
380+ Effect : 'Allow' ,
381+ Resource : 'arn:aws:events:*:*:rule/some-rule' ,
382+ Action : [
383+ 'events:PutRule' ,
384+ 'events:RemoveTargets' ,
385+ 'events:PutTargets' ,
386+ 'events:DeleteRule' ,
387+ ] ,
388+ } ,
389+ {
390+ Action : [ 'events:CreateEventBus' , 'events:DeleteEventBus' ] ,
391+ Effect : 'Allow' ,
392+ Resource : 'arn:aws:events:*:*:event-bus/some-event-bus' ,
393+ } ,
394+ ] ) ,
395+ ] ) ;
396+
397+ const { Resources } = serverless . service . provider . compiledCloudFormationTemplate ;
398+
399+ expect ( Resources . CustomDashresourceDashexistingDashs3LambdaFunction . Properties . Runtime ) . to . equal ( 'nodejs22.x' ) ;
400+ expect ( Resources . CustomDashresourceDashexistingDashcupLambdaFunction . Properties . Runtime ) . to . equal ( 'nodejs22.x' ) ;
401+ expect ( Resources . CustomDashresourceDasheventDashbridgeLambdaFunction . Properties . Runtime ) . to . equal ( 'nodejs22.x' ) ;
402+ } ) ;
350403} ) ;
351404
352405describe ( 'test/unit/lib/plugins/aws/customResources/index.test.js' , ( ) => {
0 commit comments