You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixes to remove an incorrectly generated warning when using Node JS runtime <= 16 with `NodejsFunction`
Closes#26966
----
*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
cdk.Annotations.of(scope).addWarningV2('@aws-cdk/aws-lambda-nodejs:sdkV3NotInRuntime','If you are relying on AWS SDK v3 to be present in the Lambda environment already, please explicitly configure a NodeJS runtime of Node 18 or higher.');
cdk.Annotations.of(scope).addWarningV2('@aws-cdk/aws-lambda-nodejs:sdkV2NotInRuntime','If you are relying on AWS SDK v2 to be present in the Lambda environment already, please explicitly configure a NodeJS runtime of Node 16 or lower.');
Copy file name to clipboardExpand all lines: packages/aws-cdk-lib/aws-lambda-nodejs/test/bundling.test.ts
+36Lines changed: 36 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -882,6 +882,24 @@ test('bundling with <= Node16 warns when sdk v3 is external', () => {
882
882
);
883
883
});
884
884
885
+
test('bundling with <= Node16 does not warn with default externalModules',()=>{
886
+
constmyStack=newStack(app,'MyTestStack2');
887
+
Bundling.bundle(myStack,{
888
+
entry,
889
+
projectRoot,
890
+
depsLockFilePath,
891
+
runtime: Runtime.NODEJS_16_X,
892
+
architecture: Architecture.X86_64,
893
+
});
894
+
895
+
Annotations.fromStack(myStack).hasNoWarning('*',
896
+
'If you are relying on AWS SDK v3 to be present in the Lambda environment already, please explicitly configure a NodeJS runtime of Node 18 or higher. [ack: @aws-cdk/aws-lambda-nodejs:sdkV3NotInRuntime]',
897
+
);
898
+
Annotations.fromStack(myStack).hasNoWarning('*',
899
+
'If you are relying on AWS SDK v2 to be present in the Lambda environment already, please explicitly configure a NodeJS runtime of Node 16 or lower. [ack: @aws-cdk/aws-lambda-nodejs:sdkV2NotInRuntime]',
900
+
);
901
+
});
902
+
885
903
test('bundling with >= Node18 warns when sdk v3 is external',()=>{
886
904
Bundling.bundle(stack,{
887
905
entry,
@@ -897,6 +915,24 @@ test('bundling with >= Node18 warns when sdk v3 is external', () => {
897
915
);
898
916
});
899
917
918
+
test('bundling with >= Node18 does not warn with default externalModules',()=>{
919
+
constmyStack=newStack(app,'MyTestStack3');
920
+
Bundling.bundle(myStack,{
921
+
entry,
922
+
projectRoot,
923
+
depsLockFilePath,
924
+
runtime: Runtime.NODEJS_18_X,
925
+
architecture: Architecture.X86_64,
926
+
});
927
+
928
+
Annotations.fromStack(myStack).hasNoWarning('*',
929
+
'If you are relying on AWS SDK v3 to be present in the Lambda environment already, please explicitly configure a NodeJS runtime of Node 18 or higher. [ack: @aws-cdk/aws-lambda-nodejs:sdkV3NotInRuntime]',
930
+
);
931
+
Annotations.fromStack(myStack).hasNoWarning('*',
932
+
'If you are relying on AWS SDK v2 to be present in the Lambda environment already, please explicitly configure a NodeJS runtime of Node 16 or lower. [ack: @aws-cdk/aws-lambda-nodejs:sdkV2NotInRuntime]',
933
+
);
934
+
});
935
+
900
936
test('bundling with NODEJS_LATEST warns when any dependencies are external',()=>{
0 commit comments