@@ -428,6 +428,81 @@ describe('test/unit/lib/plugins/aws/customResources/index.test.js', () => {
428428 expect ( properties . FunctionName . endsWith ( 'testing-custom-resource-apigw-cw-role' ) ) . to . be . true ;
429429 } ) ;
430430
431+ it ( 'falls back to nodejs22 runtime for CW custom resource if provider runtime is not nodejs ' , async ( ) => {
432+ const { cfTemplate } = await runServerless ( {
433+ fixture : 'api-gateway' ,
434+ command : 'package' ,
435+ options : { stage : 'testing' } ,
436+ configExt : {
437+ provider : {
438+ runtime : 'python3.12' ,
439+ logs : {
440+ restApi : true ,
441+ } ,
442+ } ,
443+ } ,
444+ } ) ;
445+
446+ const properties =
447+ cfTemplate . Resources . CustomDashresourceDashapigwDashcwDashroleLambdaFunction . Properties ;
448+ expect ( properties . Runtime ) . to . equal ( 'nodejs22.x' ) ;
449+ } ) ;
450+
451+ it ( 'falls back to nodejs22 runtime for Cognito UP custom resource if provider runtime is not nodejs ' , async ( ) => {
452+ const { cfTemplate } = await runServerless ( {
453+ fixture : 'cognito-user-pool' ,
454+ command : 'package' ,
455+ options : { stage : 'testing' } ,
456+ configExt : {
457+ provider : {
458+ runtime : 'python3.12' ,
459+ } ,
460+ } ,
461+ } ) ;
462+
463+ const properties =
464+ cfTemplate . Resources . CustomDashresourceDashexistingDashcupLambdaFunction . Properties ;
465+ expect ( properties . Runtime ) . to . equal ( 'nodejs22.x' ) ;
466+ } ) ;
467+
468+ it ( 'falls back to nodejs22 runtime for Event Bridge [LEGACY] custom resource if provider runtime is not nodejs ' , async ( ) => {
469+ const { cfTemplate } = await runServerless ( {
470+ fixture : 'event-bridge' ,
471+ command : 'package' ,
472+ options : { stage : 'testing' } ,
473+ configExt : {
474+ disabledDeprecations : [ 'AWS_EVENT_BRIDGE_CUSTOM_RESOURCE_LEGACY_OPT_IN' ] ,
475+ provider : {
476+ runtime : 'python3.12' ,
477+ eventBridge : {
478+ useCloudFormation : false ,
479+ } ,
480+ } ,
481+ } ,
482+ } ) ;
483+
484+ const properties =
485+ cfTemplate . Resources . CustomDashresourceDasheventDashbridgeLambdaFunction . Properties ;
486+ expect ( properties . Runtime ) . to . equal ( 'nodejs22.x' ) ;
487+ } ) ;
488+
489+ it ( 'falls back to nodejs22 runtime for S3 custom resource if provider runtime is not nodejs ' , async ( ) => {
490+ const { cfTemplate } = await runServerless ( {
491+ fixture : 's3' ,
492+ command : 'package' ,
493+ options : { stage : 'testing' } ,
494+ configExt : {
495+ provider : {
496+ runtime : 'python3.12' ,
497+ } ,
498+ } ,
499+ } ) ;
500+
501+ const properties =
502+ cfTemplate . Resources . CustomDashresourceDashexistingDashs3LambdaFunction . Properties ;
503+ expect ( properties . Runtime ) . to . equal ( 'nodejs22.x' ) ;
504+ } ) ;
505+
431506 it ( 'correctly takes stage from config into account when constructing apiGatewayCloudWatchRole resource' , async ( ) => {
432507 const { cfTemplate } = await runServerless ( {
433508 fixture : 'api-gateway' ,
0 commit comments