-
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-python-alpha): The command "export" does not exist - Poetry #32762
Comments
Hi I didn't get it. Where is the new lambda.PythonLayerVersion(this, "TestLayer", {
entry: path.join(__dirname, "../layer"),
description: "Test Lambda Layer with Poetry dependencies",
compatibleRuntimes: [cdk.aws_lambda.Runtime.PYTHON_3_11],
}); And this sounds like an issue from poetry 2.0 and requires a plugin from poetry to work it around? |
Hey @pahud, please check which version of There was fix for installing correct version of poetry during lambda build in In my case I was using older version of aws-cdk where poetry version wasn't locked and with recent release of poetry (v2.0.0) bundling of lambda broke because it installed poetry version 2 where poetry export was dropped. |
I'm seeing similar issues in a couple of my AWS codepipelines now. I've not been able to find any way to pin the poetry version being used by the cdk synth command. Also see this thread: |
Thank you @igorsimko @sr-rossanderson. Looks like this issue is similar to #26823 Let me verify again. |
Hi Looks at this
Looks like current I am using the
|
Yes the version pinning starts from |
This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled. |
is there any workaround for using poetry version 2.0.0? I tried to use const lambda = new PythonFunction(this, 'Lambda', {
entry: path.resolve(...),
runtime: lambda.Runtime.PYTHON_3_12,
architecture: lambda.Architecture.ARM_64,
bundling: {
buildArgs: {
POETRY_VERSION: '2.0.0',
},
},
...
}) however, that does not seem to help |
Although my overal cdk version was showing as 2.143.0, after sending logs over to AWS they discovered that I was using v2.92.0 of @aws-cdk/aws-lambda-python-alpha in a couple of my stacks. Uplifted @aws-cdk/aws-lambda-python-alpha to latest and things are looking better now. |
If updating cdk is not an option for you then you can simply patch it on your end. Instead of using python lambda construct, you can just use DockerImageFunction and use something like CDK's Dockerfile |
latest version of cdk does not solve this problem, i.e. locked version of poetry 1.5.1 in the dockerfile is not able to use new format of poetry 2.0 lock file. on the other side when using the latest poerty version as mentioned above the export command is no longer included. ...
Error: docker exited with status 1
--> Command: docker run --rm -u "502:20" -v "/...:/asset-input:delegated" -v "/.../cdk.out/asset.7edda80864b6f3bebdd458400267b3b8addd6e792b7340c5fb92551ff263c1c9:/asset-output:delegated" -w "/asset-input" cdk-da53f057a981fe2a2056d6da878d5f9c1b6d219897b44a26704be8e2efcfaeeb bash -c "rsync -rLv /asset-input/ /asset-output && cd /asset-output && poetry export --without-hashes --with-credentials --format requirements.txt --output requirements.txt && python -m pip install -r requirements.txt -t /asset-output"
at AssetStaging.bundle (/.../node_modules/.pnpm/[email protected][email protected]/node_modules/aws-cdk-lib/core/lib/asset-staging.js:2:619)
... |
@igorsimko @pahud therefore, please address this issue. thanks |
Hi As I mentioned earlier in this thread
we generally have two options:
I think it's possible via Custom Bundling but please note CDK team does not fully test the 2.0 and we still recommend the default |
Thanks, I understand that. however, is if not save to include something like that # Install the poetry-plugin-export plugin, needed for poetry versions >= 2.0.0
poetry self add poetry-plugin-export -q && \ to the docker file. that should not do anything for versions starting from poetry=1.5.1 till 2.0.0 and will also include desired export plugin starting from versions 2.0.0. is it not a good compromise i.e. is there any risk? |
Thanks for the discussion everyone! Similar to @sr-rossanderson I’ve had an older version of |
@sltmyr I see. So instead of passing the ARG override, the Dockerfile still needs
Right? It would be very struggling if CDK should bump that support as the default version but we should always allow users to use a custom Dockerfile whenever possible. Looking at the package README, I don't see any sample that allows us to use a custom Dockerfile. I guess the freedom using custom Dockerfile might be the way to go rather than just update or bump the vended one. What do you think? |
OK. I just noticed PythonLayerVersionProps allows you to specify bundling options, from where you can specify your own image. This indicates you should be allowed to provide your own bundling image with: DockerImage.fromBuild(entry); And hence using your own Dockerfile. In this case, you have the full freedom to customize your own docker image for the bundling. Is that something your are looking for? |
Yes, this is how I used my custom build image new PythonFunction(this, `Name`, {
...
bundling: {
image: DockerImage.fromRegistry("<URL-TO-DOCKER-IMAGE>"),
}
}) It's great to have this option, it's just one more thing you need to know about, set up, and re-check after updates. In my eyes it would be nice to use the new poetry version in the default image so you do not need to set up a custom build image when setting up a new python lambda with the default poetry version. |
I am having this issue and solved it by using a custom command in the bundling step. It would be great if the poetry version was pinned automatically in the bundling step.
|
Describe the bug
Our python poetry lambda deployments started failing with the error message
The command "export" does not exist
. I guess this is due to the recent poetry 2.0 release (https://github.com/python-poetry/poetry/releases/tag/2.0.0) that removes the export command and relies on the poetry-plugin-export plugin instead. The issue can be solved by using a custom build image that installs the plugin, this is the Dockerfile that worked for me: https://github.com/aws/aws-cdk/pull/32761/files.Regression Issue
Last Known Working CDK Version
No response
Expected Behavior
Lambda bundling succeeds.
Current Behavior
Bundling fails with
The command "export" does not exist
Reproduction Steps
Possible Solution
Install plugin in build image, see https://github.com/aws/aws-cdk/pull/32761/files
Additional Information/Context
No response
CDK CLI Version
2.142.1
Framework Version
No response
Node.js Version
18.0.0
OS
MacOS
Language
TypeScript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: