Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(lambda-nodejs): update default runtime #13664

Merged
merged 5 commits into from
Mar 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/@aws-cdk/aws-lambda-nodejs/lib/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export interface NodejsFunctionProps extends lambda.FunctionOptions {
* The runtime environment. Only runtimes of the Node.js family are
* supported.
*
* @default - `NODEJS_12_X` if `process.versions.node` >= '12.0.0',
* `NODEJS_10_X` otherwise.
* @default - `NODEJS_14_X` if `process.versions.node` >= '14.0.0',
* `NODEJS_12_X` otherwise.
*/
readonly runtime?: lambda.Runtime;

Expand Down Expand Up @@ -105,9 +105,9 @@ export class NodejsFunction extends lambda.Function {
// Entry and defaults
const entry = path.resolve(findEntry(id, props.entry));
const handler = props.handler ?? 'handler';
const defaultRunTime = nodeMajorVersion() >= 12
? lambda.Runtime.NODEJS_12_X
: lambda.Runtime.NODEJS_10_X;
const defaultRunTime = nodeMajorVersion() >= 14
? lambda.Runtime.NODEJS_14_X
: lambda.Runtime.NODEJS_12_X;
const runtime = props.runtime ?? defaultRunTime;

super(scope, id, {
Expand Down
6 changes: 6 additions & 0 deletions packages/@aws-cdk/aws-lambda-nodejs/test/function.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Runtime } from '@aws-cdk/aws-lambda';
import { Stack } from '@aws-cdk/core';
import { NodejsFunction } from '../lib';
import { Bundling } from '../lib/bundling';
import { nodeMajorVersion } from '../lib/util';

jest.mock('../lib/bundling', () => {
return {
Expand Down Expand Up @@ -35,8 +36,13 @@ test('NodejsFunction with .ts handler', () => {
entry: expect.stringContaining('function.test.handler1.ts'), // Automatically finds .ts handler file
}));

const runtime = nodeMajorVersion() >= 14
? Runtime.NODEJS_14_X
: Runtime.NODEJS_12_X;

expect(stack).toHaveResource('AWS::Lambda::Function', {
Handler: 'index.handler',
Runtime: runtime.name,
});
});

Expand Down