Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: Respect the package-lock.json for a NodeJS Lambda function #681

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

Merged
antonbabenko merged 3 commits into terraform-aws-modules:master from az-wegift:npm_lock_file
Aug 22, 2025

Conversation

@az-wegift
Copy link
Contributor

@az-wegift az-wegift commented May 20, 2025
edited
Loading

Description

Respect the package-lock.json so NodeJS Lambda for reproducible builds, which are critical in production environments. Similarly, like for the Poetry, copy a lock file, if such is present, to a temporary build directory. npm will use a package-lock.json file when available in a working directory.

In the example package.json, require a lower requests version to demonstrate package-lock.json usage. package.json specifies ~0.2.0 and the latest available matching version is 0.2.2, but package-lock.json freezes version 0.2.1 and that version gets installed with this change, while previously the 0.2.2 would be installed.

Motivation and Context

Breaking Changes

  • Nothing changes when package-lock.json is not present in the source directory.
  • When package-lock.json is present, it will be honoured going forward, by default, which would be an expected behaviour. This should be desired because a new version of a dependency might unexpectedly break a deployment, as mentioned in the package.py should respect package-lock.json when creating an archive for Node.js lambda functions. #423 , while locked dependencies would have been tested in unit tests. If someone doesn't want to lock their dependencies, they shouldn't have a lock file.

How Has This Been Tested?

  • I have updated at least one of the examples/* to demonstrate and validate my change(s)
    • I have added new examples to demonstrate my change and preserved old ones to demonstrate it did not break them.
  • I have tested and validated these changes using one or more of the provided examples/* projects
    • I ran terraform apply in examples/build-package/ (with commented out irrelevant Python examples for clarity).
    • In the builds directory, I checked whether the zip file's content appeared as expected.
      • Old examples install requests-0.3.0 dependency.
      • New examples install reqests-0.2.1 dependency, as expected.
  • I have executed pre-commit run -a on my pull request
    • It automatically added new examples to the list.

AnitaErnszt reacted with thumbs up emoji
@az-wegift az-wegift force-pushed the npm_lock_file branch 2 times, most recently from aadf043 to 4e390d0 Compare May 20, 2025 17:04
Respect the `package-lock.json` so NodeJS Lambda for reproducible builds
which are critical in production environments. Similarly like for the
Poetry, copy a lock file, if such is present, to a temporary build
directory. npm will use a `package-lock.json` file when available in
a working directory.
In the example `package.json`, require lower `requests` version to
demonstrate `package-lock.json` usage. `package.json` specifies
`~0.2.0` and the latest available matching version is `0.2.2`, but
`package-lock.json` freezes version `0.2.1` and that version gets
installed with this change, while previously the `0.2.2` would be
installed.
@az-wegift az-wegift changed the title (削除) feat: Respect the package-lock.json for a NodeJS Lambda function (#423) (削除ここまで) (追記) feat: Respect the package-lock.json for a NodeJS Lambda function (追記ここまで) May 20, 2025
Copy link
Contributor

@pdecat pdecat left a comment

Choose a reason for hiding this comment

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

Did not test, but code changes LGTM!

Copy link

This PR has been automatically marked as stale because it has been open 30 days
with no activity. Remove stale label or comment or this PR will be closed in 10 days

Copy link
Contributor Author

I have forked the repository, and we have been using the patched module in production at my company for almost a month now with no issues. Could it be included in the next release so that we can switch back to the original module, please?

pawelpesz reacted with thumbs up emoji

Copy link

This PR has been automatically marked as stale because it has been open 30 days
with no activity. Remove stale label or comment or this PR will be closed in 10 days

Copy link
Contributor Author

@antonbabenko, could you please consider this PR? We have used the fix in production for almost two months without any issues. It would be nice if we could switch back to the official repo.

Copy link

This PR has been automatically marked as stale because it has been open 30 days
with no activity. Remove stale label or comment or this PR will be closed in 10 days

Copy link
Contributor Author

@antonbabenko, could you please consider this PR? We have used the fix in production for almost three months without any issues. It would be nice if we could switch back to the official repo.

Copy link
Member

@antonbabenko antonbabenko left a comment

Choose a reason for hiding this comment

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

Looks good, I used Graphite to help me review it.

@antonbabenko antonbabenko merged commit 5e4391c into terraform-aws-modules:master Aug 22, 2025
30 checks passed
antonbabenko pushed a commit that referenced this pull request Aug 22, 2025
## [8.1.0](v8.0.1...v8.1.0) (2025年08月22日)
### Features
* Respect the package-lock.json for a NodeJS Lambda function ([#681](#681)) ([5e4391c](5e4391c))
Copy link
Member

This PR is included in version 8.1.0 🎉

az-wegift reacted with hooray emoji

Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 22, 2025
@az-wegift az-wegift deleted the npm_lock_file branch September 22, 2025 07:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@antonbabenko antonbabenko antonbabenko approved these changes

+1 more reviewer

@pdecat pdecat pdecat approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /