Skip to content

Commit

Permalink
chore: use node18 as default and in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mrgrain committed Sep 8, 2023
1 parent ffd4b7d commit 9ab70c3
Show file tree
Hide file tree
Showing 16 changed files with 38 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const app = new App();
const stack = new Stack(app, 'RequestAuthorizerInteg');

const authorizerFn = new lambda.Function(stack, 'MyAuthorizerFunction', {
runtime: lambda.Runtime.NODEJS_16_X,
runtime: lambda.Runtime.NODEJS_LATEST,
handler: 'index.handler',
code: lambda.AssetCode.fromAsset(path.join(__dirname, 'integ.request-authorizer.handler')),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const bucket = new s3.Bucket(stack, 'Bucket', {
autoDeleteObjects: true,
});
const lambdaFunction = new lambda.Function(stack, 'LambdaFunction', {
runtime: lambda.Runtime.NODEJS_16_X,
runtime: lambda.Runtime.NODEJS_LATEST,
handler: 'hello.handler',
code: lambda.Code.fromInline('exports.handler = {}'),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const bucket = new s3.Bucket(stack, 'Bucket', {
});
const topic = new sns.Topic(stack, 'Topic');
const lambdaFunction = new lambda.Function(stack, 'LambdaFunction', {
runtime: lambda.Runtime.NODEJS_16_X,
runtime: lambda.Runtime.NODEJS_LATEST,
handler: 'hello.handler',
code: lambda.Code.fromInline('exports.handler = {}'),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const lambdaCode = lambda.Code.fromCfnParameters();
new lambda.Function(lambdaStack, 'Lambda', {
code: lambdaCode,
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_16_X,
runtime: lambda.Runtime.NODEJS_LATEST,
});
// other resources that your Lambda needs, added to the lambdaStack...

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ test('apply boundary to role created by a custom resource', () => {
// GIVEN
const provider = CustomResourceProvider.getOrCreateProvider(stack, 'Empty', {
codeDirectory: path.join(__dirname, 'custom-resource'),
runtime: CustomResourceProviderRuntime.NODEJS_16_X,
runtime: CustomResourceProviderRuntime.NODEJS_18_X,
});

// WHEN
Expand Down
31 changes: 16 additions & 15 deletions packages/aws-cdk-lib/aws-lambda-nodejs/test/bundling.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import { PackageInstallation } from '../lib/package-installation';
import { Charset, LogLevel, OutputFormat, SourceMapMode } from '../lib/types';
import * as util from '../lib/util';

const STANDARD_RUNTIME = Runtime.NODEJS_16_X;
const STANDARD_RUNTIME = Runtime.NODEJS_18_X;
const STANDARD_TARGET = 'node18';

let detectPackageInstallationMock: jest.SpyInstance<PackageInstallation | undefined>;
const app = new App();
Expand Down Expand Up @@ -68,7 +69,7 @@ test('esbuild bundling in Docker', () => {
},
command: [
'bash', '-c',
'esbuild --bundle "/asset-input/lib/handler.ts" --target=node16 --platform=node --outfile="/asset-output/index.js" --external:aws-sdk --loader:.png=dataurl',
`esbuild --bundle "/asset-input/lib/handler.ts" --target=${STANDARD_TARGET} --platform=node --outfile="/asset-output/index.js" --external:aws-sdk --loader:.png=dataurl`,
],
workingDirectory: '/',
}),
Expand Down Expand Up @@ -98,7 +99,7 @@ test('esbuild bundling with handler named index.ts', () => {
bundling: expect.objectContaining({
command: [
'bash', '-c',
'esbuild --bundle "/asset-input/lib/index.ts" --target=node16 --platform=node --outfile="/asset-output/index.js" --external:aws-sdk',
`esbuild --bundle "/asset-input/lib/index.ts" --target=${STANDARD_TARGET} --platform=node --outfile="/asset-output/index.js" --external:aws-sdk`,
],
}),
});
Expand All @@ -120,7 +121,7 @@ test('esbuild bundling with tsx handler', () => {
bundling: expect.objectContaining({
command: [
'bash', '-c',
'esbuild --bundle "/asset-input/lib/handler.tsx" --target=node16 --platform=node --outfile="/asset-output/index.js" --external:aws-sdk',
`esbuild --bundle "/asset-input/lib/handler.tsx" --target=${STANDARD_TARGET} --platform=node --outfile="/asset-output/index.js" --external:aws-sdk`,
],
}),
});
Expand Down Expand Up @@ -173,7 +174,7 @@ test('esbuild bundling with externals and dependencies', () => {
command: [
'bash', '-c',
[
'esbuild --bundle "/asset-input/test/bundling.test.ts" --target=node16 --platform=node --outfile="/asset-output/index.js" --external:abc --external:delay',
`esbuild --bundle "/asset-input/test/bundling.test.ts" --target=${STANDARD_TARGET} --platform=node --outfile="/asset-output/index.js" --external:abc --external:delay`,
`echo \'{\"dependencies\":{\"delay\":\"${delayVersion}\"}}\' > "/asset-output/package.json"`,
'cp "/asset-input/package-lock.json" "/asset-output/package-lock.json"',
'cd "/asset-output"',
Expand Down Expand Up @@ -279,7 +280,7 @@ test('esbuild bundling source map default', () => {
command: [
'bash', '-c',
[
'esbuild --bundle "/asset-input/lib/handler.ts" --target=node16 --platform=node --outfile="/asset-output/index.js"',
`esbuild --bundle "/asset-input/lib/handler.ts" --target=${STANDARD_TARGET} --platform=node --outfile="/asset-output/index.js"`,
'--sourcemap --external:aws-sdk',
].join(' '),
],
Expand All @@ -302,7 +303,7 @@ test('esbuild bundling without aws-sdk v3 when use greater than or equal Runtime
bundling: expect.objectContaining({
command: [
'bash', '-c',
'esbuild --bundle "/asset-input/lib/handler.ts" --target=node18 --platform=node --outfile="/asset-output/index.js" --external:@aws-sdk/*',
`esbuild --bundle "/asset-input/lib/handler.ts" --target=${STANDARD_TARGET} --platform=node --outfile="/asset-output/index.js" --external:@aws-sdk/*`,
],
}),
});
Expand All @@ -326,7 +327,7 @@ test('esbuild bundling source map inline', () => {
command: [
'bash', '-c',
[
'esbuild --bundle "/asset-input/lib/handler.ts" --target=node16 --platform=node --outfile="/asset-output/index.js"',
`esbuild --bundle "/asset-input/lib/handler.ts" --target=${STANDARD_TARGET} --platform=node --outfile="/asset-output/index.js"`,
'--sourcemap=inline --external:aws-sdk',
].join(' '),
],
Expand All @@ -339,7 +340,7 @@ test('esbuild bundling is correctly done with custom runtime matching predefined
entry,
projectRoot,
depsLockFilePath,
runtime: new Runtime('nodejs16.x', RuntimeFamily.NODEJS, { supportsInlineCode: true }),
runtime: new Runtime(STANDARD_RUNTIME.name, RuntimeFamily.NODEJS, { supportsInlineCode: true }),
architecture: Architecture.X86_64,
sourceMapMode: SourceMapMode.INLINE,
});
Expand All @@ -350,7 +351,7 @@ test('esbuild bundling is correctly done with custom runtime matching predefined
command: [
'bash', '-c',
[
'esbuild --bundle "/asset-input/lib/handler.ts" --target=node16 --platform=node --outfile="/asset-output/index.js"',
`esbuild --bundle "/asset-input/lib/handler.ts" --target=${STANDARD_TARGET} --platform=node --outfile="/asset-output/index.js"`,
'--sourcemap=inline --external:aws-sdk',
].join(' '),
],
Expand All @@ -375,7 +376,7 @@ test('esbuild bundling source map enabled when only source map mode exists', ()
command: [
'bash', '-c',
[
'esbuild --bundle "/asset-input/lib/handler.ts" --target=node16 --platform=node --outfile="/asset-output/index.js"',
`esbuild --bundle "/asset-input/lib/handler.ts" --target=${STANDARD_TARGET} --platform=node --outfile="/asset-output/index.js"`,
'--sourcemap=inline --external:aws-sdk',
].join(' '),
],
Expand Down Expand Up @@ -594,7 +595,7 @@ test('esbuild bundling with projectRoot', () => {
bundling: expect.objectContaining({
command: [
'bash', '-c',
'esbuild --bundle "/asset-input/lib/index.ts" --target=node16 --platform=node --outfile="/asset-output/index.js" --external:aws-sdk --tsconfig=/asset-input/lib/custom-tsconfig.ts',
`esbuild --bundle "/asset-input/lib/index.ts" --target=${STANDARD_TARGET} --platform=node --outfile="/asset-output/index.js" --external:aws-sdk --tsconfig=/asset-input/lib/custom-tsconfig.ts`,
],
}),
});
Expand All @@ -621,7 +622,7 @@ test('esbuild bundling with projectRoot and externals and dependencies', () => {
command: [
'bash', '-c',
[
'esbuild --bundle "/asset-input/packages/aws-cdk-lib/aws-lambda-nodejs/test/bundling.test.ts" --target=node16 --platform=node --outfile="/asset-output/index.js" --external:abc --external:delay',
`esbuild --bundle "/asset-input/packages/aws-cdk-lib/aws-lambda-nodejs/test/bundling.test.ts" --target=${STANDARD_TARGET} --platform=node --outfile="/asset-output/index.js" --external:abc --external:delay`,
`echo \'{\"dependencies\":{\"delay\":\"${delayVersion}\"}}\' > "/asset-output/package.json"`,
'cp "/asset-input/common/package-lock.json" "/asset-output/package-lock.json"',
'cd "/asset-output"',
Expand Down Expand Up @@ -655,7 +656,7 @@ test('esbuild bundling with pre compilations', () => {
'bash', '-c',
[
`tsc \"/asset-input/test/bundling.test.ts\" ${compilerOptions} &&`,
'esbuild --bundle \"/asset-input/test/bundling.test.js\" --target=node16 --platform=node --outfile=\"/asset-output/index.js\" --external:aws-sdk',
`esbuild --bundle \"/asset-input/test/bundling.test.js\" --target=${STANDARD_TARGET} --platform=node --outfile=\"/asset-output/index.js\" --external:aws-sdk`,
].join(' '),
],
}),
Expand Down Expand Up @@ -863,7 +864,7 @@ test('bundling using NODEJS_LATEST doesn\'t externalize anything by default', ()
bundling: expect.objectContaining({
command: [
'bash', '-c',
'esbuild --bundle "/asset-input/lib/handler.ts" --target=node18 --platform=node --outfile="/asset-output/index.js"',
`esbuild --bundle "/asset-input/lib/handler.ts" --target=${STANDARD_TARGET} --platform=node --outfile="/asset-output/index.js"`,
],
}),
});
Expand Down
4 changes: 2 additions & 2 deletions packages/aws-cdk-lib/aws-lambda/test/function.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3037,9 +3037,9 @@ describe('function', () => {
expect(() => new lambda.Function(stack, 'MyLambda', {
code: new lambda.InlineCode('foo'),
handler: 'bar',
runtime: lambda.Runtime.NODEJS_14_X,
runtime: lambda.Runtime.NODEJS_18_X,
snapStart: lambda.SnapStartConf.ON_PUBLISHED_VERSIONS,
})).toThrowError('SnapStart currently not supported by runtime nodejs14.x');
})).toThrowError('SnapStart currently not supported by runtime nodejs18.x');
});

test('arm64 validation for snapStart', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class TestStack extends cdk.Stack {
const fn = new lambda.Function(this, 'MyLambda', {
code: new lambda.InlineCode('exports.handler = async () => { console.log(\'hello world\'); };'),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_16_X,
runtime: lambda.Runtime.NODEJS_LATEST,
});

const version = fn.currentVersion;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const awsAccountId = stack.account;
/// !show
const layer = new lambda.LayerVersion(stack, 'MyLayer', {
code: lambda.Code.fromAsset(path.join(__dirname, 'layer-code')),
compatibleRuntimes: [lambda.Runtime.NODEJS_16_X],
compatibleRuntimes: [lambda.Runtime.NODEJS_LATEST],
license: 'Apache-2.0',
description: 'A layer to test the L2 construct',
});
Expand All @@ -26,7 +26,7 @@ layer.addPermission('remote-account-grant', { accountId: awsAccountId });
new lambda.Function(stack, 'MyLayeredLambda', {
code: new lambda.InlineCode('foo'),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_16_X,
runtime: lambda.Runtime.NODEJS_LATEST,
layers: [layer],
});
/// !hide
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/aws-rds/test/integ.instance.lit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class DatabaseInstanceStack extends cdk.Stack {
const fn = new lambda.Function(this, 'Function', {
code: lambda.Code.fromInline('exports.handler = (event) => console.log(event);'),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_16_X,
runtime: lambda.Runtime.NODEJS_18_X,
});

const availabilityRule = instance.onEvent('Availability', { target: new targets.LambdaFunction(fn) });
Expand Down
5 changes: 3 additions & 2 deletions packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aw

- [Tasks for AWS Step Functions](#tasks-for-aws-step-functions)
- [Table Of Contents](#table-of-contents)
- [Paths](#paths)
- [Evaluate Expression](#evaluate-expression)
- [API Gateway](#api-gateway)
- [Call REST API Endpoint](#call-rest-api-endpoint)
- [Call HTTP API Endpoint](#call-http-api-endpoint)
- [AWS SDK](#aws-sdk)
- [AWS SDK](#aws-sdk)
- [Athena](#athena)
- [StartQueryExecution](#startqueryexecution)
- [GetQueryExecution](#getqueryexecution)
Expand Down Expand Up @@ -94,7 +95,7 @@ const convertToSeconds = new tasks.EvaluateExpression(this, 'Convert to seconds'
const createMessage = new tasks.EvaluateExpression(this, 'Create message', {
// Note: this is a string inside a string.
expression: '`Now waiting ${$.waitSeconds} seconds...`',
runtime: lambda.Runtime.NODEJS_16_X,
runtime: lambda.Runtime.NODEJS_LATEST,
resultPath: '$.message',
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface EvaluateExpressionProps extends sfn.TaskStateBaseProps {
/**
* The runtime language to use to evaluate the expression.
*
* @default lambda.Runtime.NODEJS_16_X
* @default lambda.Runtime.NODEJS_18_X
*/
readonly runtime?: lambda.Runtime;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { CUSTOMIZE_ROLES_CONTEXT_KEY } from '../../lib/helpers-internal';
import { toCloudFormation } from '../util';

const TEST_HANDLER = `${__dirname}/mock-provider`;
const STANDARD_PROVIDER = CustomResourceProviderRuntime.NODEJS_16_X;
const STANDARD_PROVIDER = CustomResourceProviderRuntime.NODEJS_18_X;

describe('custom resource provider', () => {
describe('customize roles', () => {
Expand Down Expand Up @@ -251,7 +251,7 @@ describe('custom resource provider', () => {
'Arn',
],
},
Runtime: 'nodejs16.x',
Runtime: STANDARD_PROVIDER,
},
DependsOn: [
'CustomMyResourceTypeCustomResourceProviderRoleBD5E655F',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class S3FileProvider extends Construct {
this.provider = new cr.Provider(this, 's3file-provider', {
onEventHandler: new lambda.Function(this, 's3file-on-event', {
code: lambda.Code.fromAsset(path.join(__dirname, 's3-file-handler')),
runtime: lambda.Runtime.NODEJS_16_X,
runtime: lambda.Runtime.NODEJS_18_X,
handler: 'index.onEvent',
initialPolicy: [
new iam.PolicyStatement({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { Lambda } from 'aws-sdk';
import * as setup from './hotswap-test-setup';
import { HotswapMode } from '../../../lib/api/hotswap/common';
import { Runtime } from 'aws-cdk-lib/aws-lambda';

let mockUpdateLambdaCode: (params: Lambda.Types.UpdateFunctionCodeRequest) => Lambda.Types.FunctionConfiguration;
let mockTagResource: (params: Lambda.Types.TagResourceRequest) => {};
Expand Down Expand Up @@ -31,7 +32,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('these tests do
Code: {
ZipFile: 'exports.handler = () => {return true}',
},
Runtime: 'nodejs16.x',
Runtime: Runtime.NODEJS_LATEST.name,
FunctionName: 'my-function',
},
},
Expand All @@ -47,7 +48,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('these tests do
Code: {
ZipFile: newCode,
},
Runtime: 'nodejs16.x',
Runtime: Runtime.NODEJS_LATEST.name,
FunctionName: 'my-function',
},
},
Expand Down
2 changes: 1 addition & 1 deletion tools/@aws-cdk/prlint/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Pull Request Linter
description: Execute validation rules on GitHub Pull Requests
runs:
using: node16
using: node18
main: index.js

0 comments on commit 9ab70c3

Please sign in to comment.