Skip to content

Commit 9d7d51d

Browse files
author
gleb-centrica
committed
Fix: update nodejs version to 22.x for custom resource lambdas
1 parent 5c98cac commit 9d7d51d

File tree

2 files changed

+73
-1
lines changed

2 files changed

+73
-1
lines changed

lib/plugins/aws/custom-resources/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ async function addCustomResourceToService(awsProvider, resourceName, iamRoleStat
162162
});
163163
}
164164

165-
let runtimeVersion = 'nodejs18.x';
165+
let runtimeVersion = 'nodejs22.x';
166166
const providerRuntime = awsProvider.getRuntime();
167167
if (providerRuntime.startsWith('nodejs')) {
168168
runtimeVersion = providerRuntime;

test/unit/lib/plugins/aws/custom-resources/index.test.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,78 @@ 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 = cfTemplate.Resources.CustomDashresourceDashapigwDashcwDashroleLambdaFunction.Properties;
447+
expect(properties.Runtime).to.equal('nodejs22.x');
448+
});
449+
450+
it('falls back to nodejs22 runtime for Cognito UP custom resource if provider runtime is not nodejs ', async () => {
451+
const { cfTemplate } = await runServerless({
452+
fixture: 'cognito-user-pool',
453+
command: 'package',
454+
options: { stage: 'testing' },
455+
configExt: {
456+
provider: {
457+
runtime: 'python3.12',
458+
},
459+
},
460+
});
461+
462+
const properties = cfTemplate.Resources.CustomDashresourceDashexistingDashcupLambdaFunction.Properties;
463+
expect(properties.Runtime).to.equal('nodejs22.x');
464+
});
465+
466+
it('falls back to nodejs22 runtime for Event Bridge [LEGACY] custom resource if provider runtime is not nodejs ', async () => {
467+
const { cfTemplate } = await runServerless({
468+
fixture: 'event-bridge',
469+
command: 'package',
470+
options: { stage: 'testing' },
471+
configExt: {
472+
disabledDeprecations: ['AWS_EVENT_BRIDGE_CUSTOM_RESOURCE_LEGACY_OPT_IN'],
473+
provider: {
474+
runtime: 'python3.12',
475+
eventBridge: {
476+
useCloudFormation: false,
477+
},
478+
},
479+
},
480+
});
481+
482+
const properties = cfTemplate.Resources.CustomDashresourceDasheventDashbridgeLambdaFunction.Properties;
483+
expect(properties.Runtime).to.equal('nodejs22.x');
484+
});
485+
486+
it('falls back to nodejs22 runtime for S3 custom resource if provider runtime is not nodejs ', async () => {
487+
const { cfTemplate } = await runServerless({
488+
fixture: 's3',
489+
command: 'package',
490+
options: { stage: 'testing' },
491+
configExt: {
492+
provider: {
493+
runtime: 'python3.12',
494+
},
495+
},
496+
});
497+
498+
const properties = cfTemplate.Resources.CustomDashresourceDashexistingDashs3LambdaFunction.Properties;
499+
expect(properties.Runtime).to.equal('nodejs22.x');
500+
});
501+
502+
431503
it('correctly takes stage from config into account when constructing apiGatewayCloudWatchRole resource', async () => {
432504
const { cfTemplate } = await runServerless({
433505
fixture: 'api-gateway',

0 commit comments

Comments
 (0)