Skip to content
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

fix(lambda-nodejs): aws-sdk version detection broken for self-defined runtimes #23416

Merged

Conversation

LarsFronius
Copy link
Contributor

@LarsFronius LarsFronius commented Dec 21, 2022

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:

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 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

@gitpod-io
Copy link

gitpod-io bot commented Dec 21, 2022

@github-actions github-actions bot added p2 beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK labels Dec 21, 2022
@aws-cdk-automation aws-cdk-automation requested a review from a team December 21, 2022 09:33
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

@LarsFronius LarsFronius changed the title [aws-lambda-nodejs] This is to fix runtime detection used for external-modules for custom node versions [aws-lambda-nodejs] This is to fix runtime detection used for external-modules of custom node versions Dec 21, 2022
@LarsFronius LarsFronius changed the title [aws-lambda-nodejs] This is to fix runtime detection used for external-modules of custom node versions fix(aws-lambda-nodejs) This is to fix runtime detection used for external-modules of custom node versions Dec 21, 2022
@LarsFronius LarsFronius changed the title fix(aws-lambda-nodejs) This is to fix runtime detection used for external-modules of custom node versions fix(aws-lambda-nodejs): This is to fix runtime detection used for external-modules of custom node versions Dec 21, 2022
@LarsFronius LarsFronius changed the title fix(aws-lambda-nodejs): This is to fix runtime detection used for external-modules of custom node versions fix(aws-lambda-nodejs): Fix node sdk v2 runtime detection for "custom" node runtimes Dec 21, 2022
@LarsFronius LarsFronius changed the title fix(aws-lambda-nodejs): Fix node sdk v2 runtime detection for "custom" node runtimes fix(aws-lambda-nodejs): Fix node sdk v2 runtime detection for self-defined node runtimes Dec 21, 2022
@aws-cdk-automation
Copy link
Collaborator

This PR has been in the CHANGES REQUESTED state for 3 weeks, and looks abandoned. To keep this PR from being closed, please continue work on it. If not, it will automatically be closed in a week.

@aws-cdk-automation
Copy link
Collaborator

This PR has been deemed to be abandoned, and will be automatically closed. Please create a new PR for these changes if you think this decision has been made in error.

@aws-cdk-automation aws-cdk-automation added the closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. label Jan 20, 2023
@LarsFronius LarsFronius changed the title fix(aws-lambda-nodejs): Fix node sdk v2 runtime detection for self-defined node runtimes fix(lambda-nodejs): Fix node sdk v2 runtime detection for self-defined node runtimes Jan 20, 2023
@LarsFronius
Copy link
Contributor Author

Does this change suffice the creation of an integration test? /cc @mrgrain as you reviewed the original work in #22976, maybe you can have a look?

mrgrain
mrgrain previously approved these changes Jan 20, 2023
Copy link
Contributor

@mrgrain mrgrain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that's all good. Sorry this PR slipped through under my radar. 😬

@mrgrain mrgrain reopened this Jan 20, 2023
@mrgrain mrgrain added pr-linter/exempt-integ-test The PR linter will not require integ test changes and removed closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. labels Jan 20, 2023
@mrgrain
Copy link
Contributor

mrgrain commented Jan 20, 2023

@Mergifyio update

@aws-cdk-automation aws-cdk-automation dismissed their stale review January 20, 2023 09:30

✅ Updated pull request passes all PRLinter validations. Dissmissing previous PRLinter review.

@mergify
Copy link
Contributor

mergify bot commented Jan 20, 2023

update

❌ Base branch update has failed

refusing to allow a GitHub App to create or update workflow .github/workflows/github-merit-badger.yml without workflows permission
err-code: 9D9AF

@mergify
Copy link
Contributor

mergify bot commented Jan 20, 2023

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mrgrain mrgrain changed the title fix(lambda-nodejs): Fix node sdk v2 runtime detection for self-defined node runtimes fix(lambda-nodejs): sdk v2 runtime detection broken for self-defined runtimes Jan 20, 2023
@mrgrain mrgrain changed the title fix(lambda-nodejs): sdk v2 runtime detection broken for self-defined runtimes fix(lambda-nodejs): aws-sdk version detection broken for self-defined runtimes Jan 20, 2023
@mergify
Copy link
Contributor

mergify bot commented Jan 20, 2023

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot dismissed mrgrain’s stale review January 20, 2023 10:24

Pull request has been modified.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: a7e48d5
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify
Copy link
Contributor

mergify bot commented Jan 20, 2023

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 8a7dffd into aws:main Jan 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK p2 pr-linter/exempt-integ-test The PR linter will not require integ test changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants