Skip to content

Commit 7a1808a

Browse files
authored
Merge pull request #100 from gleb-centrica/update_nodejs_custom_resource
Fix: update nodejs version to 22.x for custom resource lambdas
2 parents 7623756 + 19a3c7e commit 7a1808a

File tree

2 files changed

+76
-1
lines changed

2 files changed

+76
-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: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)