Skip to content

Commit bdce16c

Browse files
authored
fix(lambda): update default runtimes and tests to node 16 everywhere (#26921)
Upgrades a few runtime versions from `NODEJS_14_X` (which is EOL and will enter Deprecation Phase 1 on Nov 27, 2023) to `NODEJS_16_X`. Also updates all the tests. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent fe930a5 commit bdce16c

File tree

827 files changed

+139278
-12668
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

827 files changed

+139278
-12668
lines changed

INTEGRATION_TESTS.md

+11-9
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
This document describes the purpose of integration tests as well as acting as a guide
44
on what type of changes require integrations tests and how you should write integration tests.
55

6-
- [What are CDK Integration Tests](#what-are-cdk-integration-tests)
7-
- [When are integration tests required](#when-are-integration-tests-required)
8-
- [How to write Integration Tests](#how-to-write-integration-tests)
9-
- [Creating a test](#creating-a-test)
10-
- [New L2 Constructs](#new-l2-constructs)
11-
- [Existing L2 Constructs](#existing-l2-constructs)
12-
- [Assertions](#assertions)
13-
- [Running Integration Tests](#running-integration-tests)
6+
- [Integration Tests](#integration-tests)
7+
- [What are CDK Integration Tests](#what-are-cdk-integration-tests)
8+
- [When are Integration Tests Required](#when-are-integration-tests-required)
9+
- [How to write Integration Tests](#how-to-write-integration-tests)
10+
- [Creating a Test](#creating-a-test)
11+
- [New L2 Constructs](#new-l2-constructs)
12+
- [Existing L2 Constructs](#existing-l2-constructs)
13+
- [Assertions](#assertions)
14+
- [Running Integration Tests](#running-integration-tests)
15+
- [Running large numbers of Tests](#running-large-numbers-of-tests)
1416

1517
## What are CDK Integration Tests
1618

@@ -94,7 +96,7 @@ const stack = new cdk.Stack(app, 'aws-cdk-lambda-1');
9496
const fn = new lambda.Function(stack, 'MyLambda', {
9597
code: new lambda.InlineCode('foo'),
9698
handler: 'index.handler',
97-
runtime: lambda.Runtime.NODEJS_14_X,
99+
runtime: lambda.Runtime.NODEJS_LATEST,
98100
});
99101

100102
new integ.IntegTest(app, 'LambdaTest', {

design/code-asset-metadata.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ const resource = new serverless.CfnFunction(this, 'Func', {
7575
bucket: asset.s3BucketName,
7676
key: asset.s3ObjectKey
7777
},
78-
runtime: 'nodejs8.10',
78+
runtime: 'nodejs18.x',
7979
handler: 'index.handler'
8080
});
8181

design/construct-tree.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ This is a Lambda function that has it’s handler code written as an asset:
7676

7777
```typescript
7878
new lambda.Function(this, 'HelloWorldHandler', {
79-
runtime: lambda.Runtime.NODE_JS_8_10,
79+
runtime: lambda.Runtime.NODEJS_LATEST,
8080
code: lambda.Code.directory('lambda'),
8181
handler: 'hello.handler'
8282
});
@@ -119,19 +119,19 @@ The construct tree will be a list of paths that are indexed into a map of constr
119119

120120
### Construct properties
121121

122-
|Property |Type |Required |Source | Description |
123-
|--- |--- |--- |--- | --- |
124-
|path |string |Required |`construct.node.path` | Full, absolute path of the construct within the tree |
125-
|children |Array |Not Required |`construct.node.children` | All direct children of this construct. Array of the absolute paths of the constructs. Will be used to walk entire list of constructs |
126-
|attributes |Array |Not Required |`construct.node.attributes` | Attributes describing all constructs/resources/properties that are encapsulated by the construct |
122+
| Property | Type | Required | Source | Description |
123+
| ---------- | ------ | ------------ | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
124+
| path | string | Required | `construct.node.path` | Full, absolute path of the construct within the tree |
125+
| children | Array | Not Required | `construct.node.children` | All direct children of this construct. Array of the absolute paths of the constructs. Will be used to walk entire list of constructs |
126+
| attributes | Array | Not Required | `construct.node.attributes` | Attributes describing all constructs/resources/properties that are encapsulated by the construct |
127127

128128
### Metadata Properties
129129

130130
The following metadata properties will be included by the construct that produces the `tree.json` output.
131131

132-
|Property |Type |Required | Description |
133-
|--- |--- |--- | --- |
134-
|attributes |Array |Not Required | constructs can fill in arbitrary metadata such as configuration, type, properties, etc |
132+
| Property | Type | Required | Description |
133+
| ---------- | ----- | ------------ | -------------------------------------------------------------------------------------- |
134+
| attributes | Array | Not Required | constructs can fill in arbitrary metadata such as configuration, type, properties, etc |
135135

136136
Attributes are an extensible list and their keys should be namespaced by convention to avoid conflicts.
137137

packages/@aws-cdk-testing/cli-integ/resources/cdk-apps/app/app.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -222,19 +222,19 @@ class LambdaStack extends cdk.Stack {
222222
// see the 'upgrade legacy bootstrap stack' test
223223
const synthesizer = parent.node.tryGetContext('legacySynth') === 'true' ?
224224
new LegacyStackSynthesizer({
225-
fileAssetsBucketName: parent.node.tryGetContext('bootstrapBucket'),
225+
fileAssetsBucketName: parent.node.tryGetContext('bootstrapBucket'),
226+
})
227+
: new DefaultStackSynthesizer({
228+
fileAssetsBucketName: parent.node.tryGetContext('bootstrapBucket'),
226229
})
227-
: new DefaultStackSynthesizer({
228-
fileAssetsBucketName: parent.node.tryGetContext('bootstrapBucket'),
229-
})
230230
super(parent, id, {
231231
...props,
232232
synthesizer: synthesizer,
233233
});
234234

235235
const fn = new lambda.Function(this, 'my-function', {
236236
code: lambda.Code.asset(path.join(__dirname, 'lambda')),
237-
runtime: lambda.Runtime.NODEJS_14_X,
237+
runtime: lambda.Runtime.NODEJS_LATEST,
238238
handler: 'index.handler'
239239
});
240240

@@ -248,7 +248,7 @@ class LambdaHotswapStack extends cdk.Stack {
248248

249249
const fn = new lambda.Function(this, 'my-function', {
250250
code: lambda.Code.asset(path.join(__dirname, 'lambda')),
251-
runtime: lambda.Runtime.NODEJS_14_X,
251+
runtime: lambda.Runtime.NODEJS_LATEST,
252252
handler: 'index.handler',
253253
description: process.env.DYNAMIC_LAMBDA_PROPERTY_VALUE ?? "description",
254254
environment: {

packages/@aws-cdk-testing/cli-integ/resources/cdk-apps/sam_cdk_integ_app/src/docker/DockerImageFunctionConstruct/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM public.ecr.aws/lambda/nodejs:14
1+
FROM public.ecr.aws/lambda/nodejs:18
22

33
# Assumes your function is named "app.js", and there is a package.json file in the app directory
44
COPY app.js package.json ./

packages/@aws-cdk-testing/cli-integ/resources/cli-regression-patches/v1.130.0/app/app.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class OutputsStack extends cdk.Stack {
109109
constructor(parent, id, props) {
110110
super(parent, id, props);
111111

112-
const topic = new sns.Topic(this, 'MyOutput', {
112+
const topic = new sns.Topic(this, 'MyOutput', {
113113
topicName: `${cdk.Stack.of(this).stackName}MyTopic`
114114
});
115115

@@ -195,7 +195,7 @@ class LambdaStack extends cdk.Stack {
195195

196196
const fn = new lambda.Function(this, 'my-function', {
197197
code: lambda.Code.asset(path.join(__dirname, 'lambda')),
198-
runtime: lambda.Runtime.NODEJS_12_X,
198+
runtime: lambda.Runtime.NODEJS_LATEST,
199199
handler: 'index.handler'
200200
});
201201

@@ -339,7 +339,7 @@ switch (stackSet) {
339339
if (process.env.ENABLE_VPC_TESTING === 'DEFINE')
340340
new DefineVpcStack(app, `${stackPrefix}-define-vpc`, { env });
341341
if (process.env.ENABLE_VPC_TESTING === 'IMPORT')
342-
new ImportVpcStack(app, `${stackPrefix}-import-vpc`, { env });
342+
new ImportVpcStack(app, `${stackPrefix}-import-vpc`, { env });
343343
}
344344

345345
new ConditionalResourceStack(app, `${stackPrefix}-conditional-resource`)

packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/authorizers/integ.request-authorizer.lit.js.snapshot/RequestAuthorizerInteg.assets.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
{
2-
"version": "29.0.0",
2+
"version": "34.0.0",
33
"files": {
4-
"3dc8c5549b88fef617feef923524902b3650973ae1159c9489ee8405344dd5a0": {
4+
"32958f9442f31389bed730b768bd21f066c7343a5d0e87b9cad92b365e9d3c37": {
55
"source": {
6-
"path": "asset.3dc8c5549b88fef617feef923524902b3650973ae1159c9489ee8405344dd5a0.handler",
6+
"path": "asset.32958f9442f31389bed730b768bd21f066c7343a5d0e87b9cad92b365e9d3c37.handler",
77
"packaging": "zip"
88
},
99
"destinations": {
1010
"current_account-current_region": {
1111
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12-
"objectKey": "3dc8c5549b88fef617feef923524902b3650973ae1159c9489ee8405344dd5a0.zip",
12+
"objectKey": "32958f9442f31389bed730b768bd21f066c7343a5d0e87b9cad92b365e9d3c37.zip",
1313
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
1414
}
1515
}
1616
},
17-
"a605b6be7a978439cf7b93d6214f4ce6d30a9163415575fa17ba0a5857238906": {
17+
"2e7d8bf0e8057cc8d78fd4928137f285242b175a548bbcf501299a118037c8d1": {
1818
"source": {
1919
"path": "RequestAuthorizerInteg.template.json",
2020
"packaging": "file"
2121
},
2222
"destinations": {
2323
"current_account-current_region": {
2424
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
25-
"objectKey": "a605b6be7a978439cf7b93d6214f4ce6d30a9163415575fa17ba0a5857238906.json",
25+
"objectKey": "2e7d8bf0e8057cc8d78fd4928137f285242b175a548bbcf501299a118037c8d1.json",
2626
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
2727
}
2828
}

packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/authorizers/integ.request-authorizer.lit.js.snapshot/RequestAuthorizerInteg.template.json

+39-39
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,16 @@
3838
"S3Bucket": {
3939
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
4040
},
41-
"S3Key": "3dc8c5549b88fef617feef923524902b3650973ae1159c9489ee8405344dd5a0.zip"
41+
"S3Key": "32958f9442f31389bed730b768bd21f066c7343a5d0e87b9cad92b365e9d3c37.zip"
4242
},
43+
"Handler": "index.handler",
4344
"Role": {
4445
"Fn::GetAtt": [
4546
"MyAuthorizerFunctionServiceRole8A34C19E",
4647
"Arn"
4748
]
4849
},
49-
"Handler": "index.handler",
50-
"Runtime": "nodejs14.x"
50+
"Runtime": "nodejs16.x"
5151
},
5252
"DependsOn": [
5353
"MyAuthorizerFunctionServiceRole8A34C19E"
@@ -191,10 +191,10 @@
191191
"MyRestApiDeploymentB555B582d83364d66d67f510f848797cd89349d5": {
192192
"Type": "AWS::ApiGateway::Deployment",
193193
"Properties": {
194+
"Description": "Automatically created by the RestApi construct",
194195
"RestApiId": {
195196
"Ref": "MyRestApi2D1F47A9"
196-
},
197-
"Description": "Automatically created by the RestApi construct"
197+
}
198198
},
199199
"DependsOn": [
200200
"MyAuthorizer6575980E",
@@ -207,12 +207,12 @@
207207
"MyRestApiDeploymentStageprodC33B8E5F": {
208208
"Type": "AWS::ApiGateway::Stage",
209209
"Properties": {
210-
"RestApiId": {
211-
"Ref": "MyRestApi2D1F47A9"
212-
},
213210
"DeploymentId": {
214211
"Ref": "MyRestApiDeploymentB555B582d83364d66d67f510f848797cd89349d5"
215212
},
213+
"RestApiId": {
214+
"Ref": "MyRestApi2D1F47A9"
215+
},
216216
"StageName": "prod"
217217
},
218218
"DependsOn": [
@@ -222,20 +222,11 @@
222222
"MyRestApiANY05143F93": {
223223
"Type": "AWS::ApiGateway::Method",
224224
"Properties": {
225-
"HttpMethod": "ANY",
226-
"ResourceId": {
227-
"Fn::GetAtt": [
228-
"MyRestApi2D1F47A9",
229-
"RootResourceId"
230-
]
231-
},
232-
"RestApiId": {
233-
"Ref": "MyRestApi2D1F47A9"
234-
},
235225
"AuthorizationType": "CUSTOM",
236226
"AuthorizerId": {
237227
"Ref": "MyAuthorizer6575980E"
238228
},
229+
"HttpMethod": "ANY",
239230
"Integration": {
240231
"IntegrationResponses": [
241232
{
@@ -252,7 +243,16 @@
252243
{
253244
"StatusCode": "200"
254245
}
255-
]
246+
],
247+
"ResourceId": {
248+
"Fn::GetAtt": [
249+
"MyRestApi2D1F47A9",
250+
"RootResourceId"
251+
]
252+
},
253+
"RestApiId": {
254+
"Ref": "MyRestApi2D1F47A9"
255+
}
256256
}
257257
},
258258
"MyRestApiauth918A22B9": {
@@ -273,17 +273,11 @@
273273
"MyRestApiauthANY12A3CAB7": {
274274
"Type": "AWS::ApiGateway::Method",
275275
"Properties": {
276-
"HttpMethod": "ANY",
277-
"ResourceId": {
278-
"Ref": "MyRestApiauth918A22B9"
279-
},
280-
"RestApiId": {
281-
"Ref": "MyRestApi2D1F47A9"
282-
},
283276
"AuthorizationType": "CUSTOM",
284277
"AuthorizerId": {
285278
"Ref": "MySecondAuthorizer25A69B96"
286279
},
280+
"HttpMethod": "ANY",
287281
"Integration": {
288282
"IntegrationResponses": [
289283
{
@@ -300,17 +294,18 @@
300294
{
301295
"StatusCode": "200"
302296
}
303-
]
297+
],
298+
"ResourceId": {
299+
"Ref": "MyRestApiauth918A22B9"
300+
},
301+
"RestApiId": {
302+
"Ref": "MyRestApi2D1F47A9"
303+
}
304304
}
305305
},
306306
"MyAuthorizer6575980E": {
307307
"Type": "AWS::ApiGateway::Authorizer",
308308
"Properties": {
309-
"Name": "RequestAuthorizerIntegMyAuthorizer5D9D41C5",
310-
"RestApiId": {
311-
"Ref": "MyRestApi2D1F47A9"
312-
},
313-
"Type": "REQUEST",
314309
"AuthorizerUri": {
315310
"Fn::Join": [
316311
"",
@@ -360,17 +355,17 @@
360355
]
361356
]
362357
},
363-
"IdentitySource": "method.request.header.Authorization,method.request.querystring.allow"
358+
"IdentitySource": "method.request.header.Authorization,method.request.querystring.allow",
359+
"Name": "RequestAuthorizerIntegMyAuthorizer5D9D41C5",
360+
"RestApiId": {
361+
"Ref": "MyRestApi2D1F47A9"
362+
},
363+
"Type": "REQUEST"
364364
}
365365
},
366366
"MySecondAuthorizer25A69B96": {
367367
"Type": "AWS::ApiGateway::Authorizer",
368368
"Properties": {
369-
"Name": "RequestAuthorizerIntegMySecondAuthorizerCCC4ECED",
370-
"RestApiId": {
371-
"Ref": "MyRestApi2D1F47A9"
372-
},
373-
"Type": "REQUEST",
374369
"AuthorizerUri": {
375370
"Fn::Join": [
376371
"",
@@ -420,7 +415,12 @@
420415
]
421416
]
422417
},
423-
"IdentitySource": "method.request.header.Authorization,method.request.querystring.allow"
418+
"IdentitySource": "method.request.header.Authorization,method.request.querystring.allow",
419+
"Name": "RequestAuthorizerIntegMySecondAuthorizerCCC4ECED",
420+
"RestApiId": {
421+
"Ref": "MyRestApi2D1F47A9"
422+
},
423+
"Type": "REQUEST"
424424
}
425425
}
426426
},

packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/authorizers/integ.request-authorizer.lit.js.snapshot/asset.32958f9442f31389bed730b768bd21f066c7343a5d0e87b9cad92b365e9d3c37.handler/index.js

+30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":"29.0.0"}
1+
{"version":"34.0.0"}

packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/authorizers/integ.request-authorizer.lit.js.snapshot/integ.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "29.0.0",
2+
"version": "34.0.0",
33
"testCases": {
44
"integ.request-authorizer.lit": {
55
"stacks": [

0 commit comments

Comments
 (0)