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

@aws-cdk/aws-lambda-python: require-hashes error because of pipenv==2022.4.8 #21713

Closed
avanderm opened this issue Aug 22, 2022 · 3 comments
Closed
Assignees
Labels
@aws-cdk/aws-lambda-python bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@avanderm
Copy link

Describe the bug

Bundling of poetry packages fails, since some packages do not receive hashes. Also referenced in #19232

Expected Behavior

  1. Adds all the hashes to requirements.txt in the Docker build
  2. Does not write the requirements.txt file into the local code folder

Current Behavior

Error notification:

ERROR: Hashes are required in --require-hashes mode, but they are missing from some requirements. Here is a list of those requirements along with the hashes their downloaded archives actually had. Add lines like these to your requirements
 files to prevent tampering. (If you did not enable --require-hashes manually, note that it turns on automatically when any package has a hash.)

Reproduction Steps

Poetry package generation in folder src relative to CDK project:

poetry new mypackage
poetry add aws-lambda-powertools
poetry install

File index.py in top level of Poetry package:

def handler(event, context):
  print(event)

Usage in CDK:

new PythonFunction(this, 'MyFunction', {
  entry: 'src/mypackage'
  runtime: Runtime.PYTHON_3_9,
});

Possible Solution

Overwrite the bundling Dockerfile to unpin the pipenv version solves the problem:

new PythonFunction(this, 'MyFunction', {
  bundling: {
    image: DockerImage.fromBuild('src/lambda-python'),
  },
  entry: 'src/mypackage'
  runtime: Runtime.PYTHON_3_9,
});

With Dockerfile found here

Additional Information/Context

No response

CDK CLI Version

2.37.1

Framework Version

No response

Node.js Version

v16.13.0

OS

Fedora release 35 (Thirty Five)

Language

Typescript

Language Version

TypeScript (3.9.7) | Python (3.9.5)

Other information

No response

@avanderm avanderm added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Aug 22, 2022
@corymhall
Copy link
Contributor

@avanderm why does unpinning the pipenv version solve the problem? Did they change this behavior in a more recent version?

@corymhall corymhall added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Aug 22, 2022
@avanderm
Copy link
Author

My mistake, turned out to be a Poetry lock issue, so will have to dig further in that direction. Closing this.

@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-lambda-python bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

2 participants