-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(aws_lambda_nodejs): esbuild failed because --external #30080
Comments
I will look into this. To work around this, you can set external modules to |
It seems the issue is related to |
@blanchma Good morning. Please advise if you were able to resolve the issue. Thanks, |
@ashishdhingra, why do you say that the SDK is not included in the NODEJS_20_X Lambda runtime? This blog post says it is. |
@scanlonp My bad, I meant AWS SDK for JavaScript v2. Apologies for the confusion. |
@ashishdhingra If it helps. It seems to be an error when escaping the This gets printed by bash -c yarn run esbuild --bundle "/Users/hakanlofcali/Code/TTS/cai/src/ingestion/lambda/enrichment/geoIPMapping/index.ts" --target=node20 --platform=node --outfile="/Users/hakanlofcali/Code/TTS/cai/cdk.out/bundling-temp-81a140cc6448b9c92ca0c55ebad23426471e0b80b5b4ee0bd21e178a8d94ffbb/index.js" --external:@aws-sdk/* What works is: bash -c yarn run esbuild --bundle "/Users/hakanlofcali/Code/TTS/cai/src/ingestion/lambda/enrichment/geoIPMapping/index.ts" --target=node20 --platform=node --outfile="/Users/hakanlofcali/Code/TTS/cai/cdk.out/bundling-temp-81a140cc6448b9c92ca0c55ebad23426471e0b80b5b4ee0bd21e178a8d94ffbb/index.js" --external:"@aws-sdk/*" Preserving literal string by double quoting seems to help. Note Below seems to be the problem. Not sure, I do not know the code base. Trying to help :)
const versionedExternals = isV2Runtime ? ['aws-sdk'] : ['@aws-sdk/*']; to const versionedExternals = isV2Runtime ? ['aws-sdk'] : ['"@aws-sdk/*"']; |
Describe the bug
Running the following CDK construct:
new aws_lambda_nodejs.NodejsFunction(this, 'RollbarNotifierLambda', { projectRoot: path.join(__dirname, '../assets/RollbarNotifier/'), entry: path.join(__dirname, '../assets/RollbarNotifier/index.js'), functionName:
${envName}-rollbar-notifier, handler: 'index.handler', memorySize: 1024, runtime: lambda.Runtime.NODEJS_20_X, timeout: Duration.seconds(300), depsLockFilePath: path.join(__dirname, '../assets/RollbarNotifier/yarn.lock') });
I got:
Error: Failed to bundle asset SodEtlStack/RollbarNotifierLambda/Code/Stage, bundle output is located at /Users/blanchma/stackwell/sod-ingestion-pipeline/sod-etl/cdk.out/bundling-temp-76055022e26f668566fb894525a4479d0199145c9f6941468063ea115c5cfab1-error: Error: bash -c yarn run esbuild --bundle "/Users/blanchma/stackwell/sod-ingestion-pipeline/sod-etl/assets/RollbarNotifier/index.js" --target=node20 --platform=node --outfile="/Users/blanchma/stackwell/sod-ingestion-pipeline/sod-etl/cdk.out/bundling-temp-76055022e26f668566fb894525a4479d0199145c9f6941468063ea115c5cfab1/index.js" --external:@aws-sdk/* run in directory /Users/blanchma/stackwell/sod-ingestion-pipeline/sod-etl/assets/RollbarNotifier/ exited with status 1
esbuild --version 0.20.2
If I run the command as shown in the error without
--external:@aws-sdk/*
it works fine.Expected Behavior
CDK bundle and deploy the function.
Current Behavior
The esbuild command line seems to be built incorrectly.
Reproduction Steps
Build a function using NodeJsFunction.
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.139.0
Framework Version
No response
Node.js Version
18.19.1
OS
macos 12.7
Language
TypeScript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: