Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(lambda-nodejs): aws-sdk version detection broken for self-defined…
… 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
- Loading branch information