Skip to content

Commit 2aa4733

Browse files
fix: lambda-nodejs default runtime regression (#26763)
Previously we changed the default version of the lambda-nodejs Function construct to go from using the `builtInNodeJsCustomResourceRuntime`, a map of regions to available versions, to `lambda.Runtime.NODEJS_18_X`. The default `externalModule` configuration excluded the aws-sdk version based on the runtime passed, excluding v2 for Node16 and under, and v3 for Node18 and up, but users can pass their own bundling configuration excluding `aws-sdk` while not explicitly passing a runtime, which caused their functions to break. Adds a new `lambda.Runtime` value for `NODEJS_LATEST`. This is central reference for the latest version of NodeJS provided by the lamdba service. It also includes a new property `isLatest` which can be used to indicate that the runtime version may change over time. This can used to indicate that relying on packages shipped with the environment may not be relied upon if the version changes. We default to using the `NODEJS_LATEST` runtime only if the feature flag is enabled. If the flag is not enabled, use `NODEJS_16_X` to keep supporting users current bundling configurations. Additionally, add a warning to tell users if they are excluding a package from their bundling that we know doesn't exist within the runtime they are using. IE, if using `NODEJS_18_X` and the exclude list includes `aws-sdk`, warn users that it won't be present. Fixes #26732 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 72481a3 commit 2aa4733

File tree

30 files changed

+33448
-59
lines changed

30 files changed

+33448
-59
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"version": "33.0.0",
3+
"files": {
4+
"fc4da43a214bb79ca557ca6c54e8dfcc4f2aabbd6672873b7b3ea417576612f5": {
5+
"source": {
6+
"path": "asset.fc4da43a214bb79ca557ca6c54e8dfcc4f2aabbd6672873b7b3ea417576612f5.bundle",
7+
"packaging": "zip"
8+
},
9+
"destinations": {
10+
"current_account-current_region": {
11+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12+
"objectKey": "fc4da43a214bb79ca557ca6c54e8dfcc4f2aabbd6672873b7b3ea417576612f5.zip",
13+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
14+
}
15+
}
16+
},
17+
"c62c808ec232ccd52772ad7eaab2455102eb17c02f23a48068cc3a0a4f8fe4f7": {
18+
"source": {
19+
"path": "LambdaNodeJsLatestIntegDefaultTestDeployAssertD40B5C28.template.json",
20+
"packaging": "file"
21+
},
22+
"destinations": {
23+
"current_account-current_region": {
24+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
25+
"objectKey": "c62c808ec232ccd52772ad7eaab2455102eb17c02f23a48068cc3a0a4f8fe4f7.json",
26+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
27+
}
28+
}
29+
}
30+
},
31+
"dockerImages": {}
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
{
2+
"Resources": {
3+
"LambdaInvoked00748c118c58ddbf17c194faa46eda2": {
4+
"Type": "Custom::DeployAssert@SdkCallLambdainvoke",
5+
"Properties": {
6+
"ServiceToken": {
7+
"Fn::GetAtt": [
8+
"SingletonFunction1488541a7b23466481b69b4408076b81HandlerCD40AE9F",
9+
"Arn"
10+
]
11+
},
12+
"service": "Lambda",
13+
"api": "invoke",
14+
"expected": "{\"$ObjectLike\":{\"StatusCode\":200,\"ExecutedVersion\":\"$LATEST\"}}",
15+
"parameters": {
16+
"FunctionName": {
17+
"Fn::Join": [
18+
"",
19+
[
20+
"\"",
21+
{
22+
"Fn::ImportValue": "cdk-integ-lambda-nodejs-latest:ExportsOutputReflatestFE0D80B6C9B17E6B"
23+
},
24+
"\""
25+
]
26+
]
27+
}
28+
},
29+
"flattenResponse": "false",
30+
"salt": "1692126177944"
31+
},
32+
"UpdateReplacePolicy": "Delete",
33+
"DeletionPolicy": "Delete"
34+
},
35+
"LambdaInvoked00748c118c58ddbf17c194faa46eda2InvokeC0A33EEB": {
36+
"Type": "AWS::Lambda::Permission",
37+
"Properties": {
38+
"Action": "lambda:InvokeFunction",
39+
"FunctionName": {
40+
"Fn::ImportValue": "cdk-integ-lambda-nodejs-latest:ExportsOutputReflatestFE0D80B6C9B17E6B"
41+
},
42+
"Principal": {
43+
"Fn::GetAtt": [
44+
"SingletonFunction1488541a7b23466481b69b4408076b81Role37ABCE73",
45+
"Arn"
46+
]
47+
}
48+
}
49+
},
50+
"SingletonFunction1488541a7b23466481b69b4408076b81Role37ABCE73": {
51+
"Type": "AWS::IAM::Role",
52+
"Properties": {
53+
"AssumeRolePolicyDocument": {
54+
"Version": "2012-10-17",
55+
"Statement": [
56+
{
57+
"Action": "sts:AssumeRole",
58+
"Effect": "Allow",
59+
"Principal": {
60+
"Service": "lambda.amazonaws.com"
61+
}
62+
}
63+
]
64+
},
65+
"ManagedPolicyArns": [
66+
{
67+
"Fn::Sub": "arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
68+
}
69+
],
70+
"Policies": [
71+
{
72+
"PolicyName": "Inline",
73+
"PolicyDocument": {
74+
"Version": "2012-10-17",
75+
"Statement": [
76+
{
77+
"Action": [
78+
"lambda:Invoke"
79+
],
80+
"Effect": "Allow",
81+
"Resource": [
82+
"*"
83+
]
84+
},
85+
{
86+
"Action": [
87+
"lambda:InvokeFunction"
88+
],
89+
"Effect": "Allow",
90+
"Resource": [
91+
{
92+
"Fn::Join": [
93+
"",
94+
[
95+
"arn:",
96+
{
97+
"Ref": "AWS::Partition"
98+
},
99+
":lambda:",
100+
{
101+
"Ref": "AWS::Region"
102+
},
103+
":",
104+
{
105+
"Ref": "AWS::AccountId"
106+
},
107+
":function:",
108+
{
109+
"Fn::ImportValue": "cdk-integ-lambda-nodejs-latest:ExportsOutputReflatestFE0D80B6C9B17E6B"
110+
}
111+
]
112+
]
113+
}
114+
]
115+
}
116+
]
117+
}
118+
}
119+
]
120+
}
121+
},
122+
"SingletonFunction1488541a7b23466481b69b4408076b81HandlerCD40AE9F": {
123+
"Type": "AWS::Lambda::Function",
124+
"Properties": {
125+
"Runtime": "nodejs18.x",
126+
"Code": {
127+
"S3Bucket": {
128+
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
129+
},
130+
"S3Key": "fc4da43a214bb79ca557ca6c54e8dfcc4f2aabbd6672873b7b3ea417576612f5.zip"
131+
},
132+
"Timeout": 120,
133+
"Handler": "index.handler",
134+
"Role": {
135+
"Fn::GetAtt": [
136+
"SingletonFunction1488541a7b23466481b69b4408076b81Role37ABCE73",
137+
"Arn"
138+
]
139+
}
140+
}
141+
}
142+
},
143+
"Outputs": {
144+
"AssertionResultsLambdaInvoked00748c118c58ddbf17c194faa46eda2": {
145+
"Value": {
146+
"Fn::GetAtt": [
147+
"LambdaInvoked00748c118c58ddbf17c194faa46eda2",
148+
"assertion"
149+
]
150+
}
151+
}
152+
},
153+
"Parameters": {
154+
"BootstrapVersion": {
155+
"Type": "AWS::SSM::Parameter::Value<String>",
156+
"Default": "/cdk-bootstrap/hnb659fds/version",
157+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
158+
}
159+
},
160+
"Rules": {
161+
"CheckBootstrapVersion": {
162+
"Assertions": [
163+
{
164+
"Assert": {
165+
"Fn::Not": [
166+
{
167+
"Fn::Contains": [
168+
[
169+
"1",
170+
"2",
171+
"3",
172+
"4",
173+
"5"
174+
],
175+
{
176+
"Ref": "BootstrapVersion"
177+
}
178+
]
179+
}
180+
]
181+
},
182+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
183+
}
184+
]
185+
}
186+
}
187+
}

packages/@aws-cdk-testing/framework-integ/test/aws-lambda-nodejs/test/integ.latest.js.snapshot/asset.50a8879346510e33e69a511e29d588e7b2d2b477b6989a4db677027bb8605b9f/index.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-lambda-nodejs/test/integ.latest.js.snapshot/asset.50a8879346510e33e69a511e29d588e7b2d2b477b6989a4db677027bb8605b9f/node_modules/.yarn-integrity

+16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-lambda-nodejs/test/integ.latest.js.snapshot/asset.50a8879346510e33e69a511e29d588e7b2d2b477b6989a4db677027bb8605b9f/node_modules/delay/index.d.ts

+107
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)