Skip to content

Commit

Permalink
fix(lambda): update default runtimes and tests to node 18 (#27066)
Browse files Browse the repository at this point in the history
Upgrades remaining runtime versions from `NODEJS_16_X` (which enters EOL on 2023-09-11 and will enter Lambda's Deprecation Phase 1 on Mar 11 2024) to NODEJS_18_X.

Also updates remaining unit & integration tests to use NODEJS_LATEST or NODEJS_18_X.
Most tests will reference the lambda runtime version via a new centralized configuration.
Updated a number of test handlers to use SDKv3 and cleaned-up some duplicated, unused handler files.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
mrgrain committed Sep 11, 2023
1 parent 5046a9b commit 04b30f3
Show file tree
Hide file tree
Showing 604 changed files with 172,417 additions and 165,891 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ class BundlingStage extends cdk.Stage {
new lambda.Function(stack, 'Handler', {
code: lambda.Code.fromAsset(path.join(__dirname, 'lambda')),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_16_X,
runtime: lambda.Runtime.NODEJS_LATEST,
});
}
}
Expand Down
3 changes: 3 additions & 0 deletions packages/@aws-cdk-testing/framework-integ/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
"@aws-cdk/cdk-build-tools": "0.0.0",
"@aws-cdk/integ-runner": "^0.0.0",
"@aws-cdk/pkglint": "0.0.0",
"@aws-sdk/client-acm": "3.408.0",
"@aws-sdk/client-rds": "3.408.0",
"@aws-sdk/client-s3": "3.408.0",
"delay": "5.0.0"
},
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
}
}
},
"2e7d8bf0e8057cc8d78fd4928137f285242b175a548bbcf501299a118037c8d1": {
"4f386f4c2e0c9ab2438dbd353ec9ab0ccb080c2c9ad43ff62d01838ab904a016": {
"source": {
"path": "RequestAuthorizerInteg.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "2e7d8bf0e8057cc8d78fd4928137f285242b175a548bbcf501299a118037c8d1.json",
"objectKey": "4f386f4c2e0c9ab2438dbd353ec9ab0ccb080c2c9ad43ff62d01838ab904a016.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"Arn"
]
},
"Runtime": "nodejs16.x"
"Runtime": "nodejs18.x"
},
"DependsOn": [
"MyAuthorizerFunctionServiceRole8A34C19E"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"validateOnSynth": false,
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/2e7d8bf0e8057cc8d78fd4928137f285242b175a548bbcf501299a118037c8d1.json",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/4f386f4c2e0c9ab2438dbd353ec9ab0ccb080c2c9ad43ff62d01838ab904a016.json",
"requiresBootstrapStackVersion": 6,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
"additionalDependencies": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
"Arn"
]
},
"runtime": "nodejs16.x"
"runtime": "nodejs18.x"
}
},
"constructInfo": {
Expand Down Expand Up @@ -720,7 +720,7 @@
"path": "Tree",
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.2.69"
"version": "10.2.70"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as path from 'path';
import * as lambda from 'aws-cdk-lib/aws-lambda';
import { App, Stack } from 'aws-cdk-lib';
import { MockIntegration, PassthroughBehavior, RestApi, RequestAuthorizer, IdentitySource } from 'aws-cdk-lib/aws-apigateway';
import { STANDARD_NODEJS_RUNTIME } from '../../../config';

// Against the RestApi endpoint from the stack output, run
// `curl -s -o /dev/null -w "%{http_code}" <url>` should return 401
Expand All @@ -12,7 +13,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: STANDARD_NODEJS_RUNTIME,
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 @@ -14,15 +14,15 @@
}
}
},
"fb708804d80325ef7f30899c91423ae60ebe0a8833e8777df39537565bb69b0b": {
"1700f94824f0c5de41fa729800151d6296945b6e5fa1536c384e04b7a1377f4c": {
"source": {
"path": "TokenAuthorizerIAMRoleInteg.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "fb708804d80325ef7f30899c91423ae60ebe0a8833e8777df39537565bb69b0b.json",
"objectKey": "1700f94824f0c5de41fa729800151d6296945b6e5fa1536c384e04b7a1377f4c.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"Arn"
]
},
"Runtime": "nodejs16.x"
"Runtime": "nodejs18.x"
},
"DependsOn": [
"MyAuthorizerFunctionServiceRole8A34C19E"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"validateOnSynth": false,
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/fb708804d80325ef7f30899c91423ae60ebe0a8833e8777df39537565bb69b0b.json",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/1700f94824f0c5de41fa729800151d6296945b6e5fa1536c384e04b7a1377f4c.json",
"requiresBootstrapStackVersion": 6,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
"additionalDependencies": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
"Arn"
]
},
"runtime": "nodejs16.x"
"runtime": "nodejs18.x"
}
},
"constructInfo": {
Expand Down Expand Up @@ -579,7 +579,7 @@
"path": "iam-token-authorizer/DefaultTest/Default",
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.2.69"
"version": "10.2.70"
}
},
"DeployAssert": {
Expand Down Expand Up @@ -625,7 +625,7 @@
"path": "Tree",
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.2.69"
"version": "10.2.70"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as lambda from 'aws-cdk-lib/aws-lambda';
import { App, Stack } from 'aws-cdk-lib';
import { IntegTest } from '@aws-cdk/integ-tests-alpha';
import { AuthorizationType, MockIntegration, PassthroughBehavior, RestApi, TokenAuthorizer } from 'aws-cdk-lib/aws-apigateway';
import { STANDARD_NODEJS_RUNTIME } from '../../../config';

/*
* Stack verification steps:
Expand All @@ -16,7 +17,7 @@ const app = new App();
const stack = new Stack(app, 'TokenAuthorizerIAMRoleInteg');

const authorizerFn = new lambda.Function(stack, 'MyAuthorizerFunction', {
runtime: lambda.Runtime.NODEJS_16_X,
runtime: STANDARD_NODEJS_RUNTIME,
handler: 'index.handler',
code: lambda.AssetCode.fromAsset(path.join(__dirname, 'integ.token-authorizer.handler')),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
}
}
},
"568e7d470f7811087df1c347caee3ce932a45d3bceb2274d3f0376ac5a8b8f72": {
"ade8b2061e29b24d8acb0dbb8d8e63847fd6feefbe140e87eb7d76ea0cee27cf": {
"source": {
"path": "TokenAuthorizerInteg.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "568e7d470f7811087df1c347caee3ce932a45d3bceb2274d3f0376ac5a8b8f72.json",
"objectKey": "ade8b2061e29b24d8acb0dbb8d8e63847fd6feefbe140e87eb7d76ea0cee27cf.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"Arn"
]
},
"Runtime": "nodejs16.x"
"Runtime": "nodejs18.x"
},
"DependsOn": [
"MyAuthorizerFunctionServiceRole8A34C19E"
Expand Down Expand Up @@ -384,7 +384,7 @@
"Arn"
]
},
"Runtime": "nodejs16.x",
"Runtime": "nodejs18.x",
"Timeout": 10
},
"DependsOn": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
{
"version": "34.0.0",
"files": {
"d69f83e949b9c49809604e7bcd3a868d44f04f936029b55662aa14982d9bd44b": {
"77997674c0a10fbb65169124ad6c0d7a664b6162ad44f9abfa22fd006b33f754": {
"source": {
"path": "asset.d69f83e949b9c49809604e7bcd3a868d44f04f936029b55662aa14982d9bd44b.bundle",
"path": "asset.77997674c0a10fbb65169124ad6c0d7a664b6162ad44f9abfa22fd006b33f754.bundle",
"packaging": "zip"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "d69f83e949b9c49809604e7bcd3a868d44f04f936029b55662aa14982d9bd44b.zip",
"objectKey": "77997674c0a10fbb65169124ad6c0d7a664b6162ad44f9abfa22fd006b33f754.zip",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
},
"32a3aac734a72e886e3c709c16dcc1dd16078db65460a952f17fbdba721411af": {
"92ac4cd48fe3ed9dff2af30d131aa768b19a417e4dab50160b7448d58e219528": {
"source": {
"path": "apigwtokenauthDefaultTestDeployAssert2CF60E05.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "32a3aac734a72e886e3c709c16dcc1dd16078db65460a952f17fbdba721411af.json",
"objectKey": "92ac4cd48fe3ed9dff2af30d131aa768b19a417e4dab50160b7448d58e219528.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"Payload": "\"{\\\"method\\\":\\\"GET\\\",\\\"authorization\\\":\\\"allow\\\"}\""
},
"flattenResponse": "false",
"salt": "1693324935277"
"salt": "1694443541803"
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
Expand Down Expand Up @@ -208,7 +208,7 @@
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
},
"S3Key": "d69f83e949b9c49809604e7bcd3a868d44f04f936029b55662aa14982d9bd44b.zip"
"S3Key": "77997674c0a10fbb65169124ad6c0d7a664b6162ad44f9abfa22fd006b33f754.zip"
},
"Timeout": 120,
"Handler": "index.handler",
Expand Down Expand Up @@ -248,7 +248,7 @@
"Payload": "\"{\\\"method\\\":\\\"GET\\\",\\\"authorization\\\":\\\"deny\\\"}\""
},
"flattenResponse": "false",
"salt": "1693324935278"
"salt": "1694443541805"
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
Expand Down Expand Up @@ -296,7 +296,7 @@
"Payload": "\"{\\\"method\\\":\\\"OPTIONS\\\"}\""
},
"flattenResponse": "false",
"salt": "1693324935278"
"salt": "1694443541806"
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
Expand Down Expand Up @@ -32329,6 +32330,7 @@ var CustomResourceHandler = class {
constructor(event, context) {
this.event = event;
this.context = context;
this.timedOut = false;
this.timeout = setTimeout(async () => {
await this.respond({
status: "FAILED",
Expand All @@ -32340,9 +32342,6 @@ var CustomResourceHandler = class {
this.event = event;
this.physicalResourceId = extractPhysicalResourceId(event);
}
physicalResourceId;
timeout;
timedOut = false;
/**
* Handles executing the custom resource event. If `stateMachineArn` is present
* in the props then trigger the waiter statemachine
Expand Down Expand Up @@ -32476,7 +32475,6 @@ var AssertionHandler = class extends CustomResourceHandler {
}
};
var MatchCreator = class {
parsedObj;
constructor(obj) {
this.parsedObj = {
matcher: obj
Expand Down Expand Up @@ -32685,7 +32683,8 @@ var AwsApiCallHandler = class extends CustomResourceHandler {
const sdkPkg = getServicePackage(request2.service);
const client = getServiceClient(sdkPkg);
const Command = getSdkCommand(sdkPkg, request2.api);
const commandInput = (request2.parameters && decodeParameters(request2.parameters)) ?? {};
const parameters = (request2.parameters && decodeParameters(request2.parameters)) ?? {};
const commandInput = (0, import_sdk_v2_to_v3_adapter.coerceApiParametersToUint8Array)(request2.service, request2.api, parameters);
console.log(`SDK request to ${sdkPkg.service}.${request2.api} with parameters ${JSON.stringify(commandInput)}`);
const response = await client.send(new Command(commandInput));
if (response.Payload) {
Expand Down
Loading

0 comments on commit 04b30f3

Please sign in to comment.