-
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): AWS SDK v2 is not available for node18.x runtime #22976
Comments
The fix in CDK should be to ignore all
|
I try to fix it #22989 . And workaround of this issue is setting empty array to extenalModules. |
…22989) This PR set default of `externalModules` aws-sdk v3 when use greater than or equal nodejs v18 runtime, because [Lambda runtime nodejs v18 includes aws-sdk v3](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html#:~:text=Node.js%2018,3.188.0). fix #22976 ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
… runtimes (#23416) We have single-sourced our node versions in our repositories into a single `.nvmrc` at the root of the repo. From there, we create the Runtimes, like so: ```typescript const nvmrc = readFileSync(path.join(__dirname, '..', '.nvmrc')).toString().trim() new Runtime(`nodejs${nvmrc}.x'`, RuntimeFamily.NODEJS, { supportsInlineCode: true }) ``` As of #22989 the detection for the appropriate command line flags that dictate which aws-sdk is considered as an external module in esbuild broke for our self-defined Lambda runtimes < node18, as the [codepath](https://github.com/aws/aws-cdk/pull/22989/files#diff-cd86fbd4f2bbefcbcffc2143adccabafa1debe5981edbcdfcc766b5a705fe770R371-R383) detecting runtime versions that ship with the aws-sdk v2 never returned a truthy result. This left us with Lambdas running node 16, that did not bundle the aws-sdk v3, as it was incorrectly set as external in the esbuild command, which should only be the case from node 18 onwards. I am thus suggesting explicitly comparing the runtimes family and name to detect whether the runtime is one shipping the aws-sdk v2, as none of the other features of the Runtime class actually have an effect on the Lambda runtime environment. Related issue: #22976
Hi @yamatatsu whats the fix for this issue? |
Hi @juztinlazaro |
Describe the bug
According to this comment, node18.x image includes the AWS SDK not v2 but v3.
The AWS SDK v2 is not included in bundles as
aws-sdk
is specified inexternalModules
by default, so sccripts which useaws-sdk
will fail when using node18.x runtime.Expected Behavior
extenalModules
for node18.x runtime should be@aws-sdk/*
.Current Behavior
Reproduction Steps
Deploy a node18.x lambda function whose handler contains
require('aws-sdk')
and run it.Possible Solution
Edit here:
aws-cdk/packages/@aws-cdk/aws-lambda-nodejs/lib/bundling.ts
Line 116 in 2c61405
Additional Information/Context
No response
CDK CLI Version
2.51.0
Framework Version
No response
Node.js Version
v16.18.0
OS
Ubuntu 22.04 LTS
Language
Typescript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: