(aws-lambda-python-alpha): Poetry 2+ unsupported in public.ecr.aws/lambda/python:3.10
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the bug
Starting in poetry version 2, dulwich is default git client of poetry. Later versions of dulwich relies on `ssh` command having `-o SetEnv` option. However public.ecr.aws/lambda/python:3.10 has very old version of `ssh` - 2017 where this option is not supported.
### Regression Issue
- [ ] Select this option if this issue appears to be a regression.
### Last Known Working CDK Library Version
_No response_
### Expected Behavior
AWS Lambda Python docker image `python:3.10` is successfully built when using poetry 2+
### Current Behavior
Cannot use `PythonFunction` construct with python version 3.10 and poetry 2+.
### Reproduction Steps
Use [PythonFunction](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-lambda-python-alpha.PythonFunction.html) construct with python runtime 3.10 and build arguments `POETRY_VERSION: 2.1.3`
```python
lambda_python.PythonFunction(
...
runtime=lambda_.Runtime.PYTHON_3_10,
bundling=lambda_python.BundlingOptions(
...
build_args={'POETRY_VERSION': 2.1.3}
),
)
```
### Possible Solution
There are 2 workarounds I can think of at the moment:
1. Use your own Dockerfile to build lambda, where you do
```Dockerfile
RUN yum install -y git
RUN poetry config system-git-client true
```
or use some newer docker image version where dulwich will work (I guess python:3.12 should work since it's using newer Amazon Linux 2023)
2. Add bundling command hook to do same thing as in step 1
```python
lambda_python.PythonFunction(
...
bundling=lambda_python.BundlingOptions(
...
command_hooks=CommandHooks(
before=lambda input, output: [
"yum install -y git",
"poetry config system-git-client true"
]
)
),
)
```
### Additional Information/Context
_No response_
### AWS CDK Library version (aws-cdk-lib)
2.171.1
### AWS CDK CLI version
2.176.0 (build 899965d)
### Node.js Version
v20.18.0
### OS
Ubuntu 24.04.1 LTS
### Language
Python
### Language Version
Python 3.10.15
### Other information
_No response_
Contributor guide
Research direction
Start at the PythonFunction construct and its BundlingOptions, then reproduce a Python 3.10 build with POETRY_VERSION 2.1.3 using public.ecr.aws/lambda/python:3.10. Compare the available ssh client and Poetry configuration with newer runtime images or the proposed hooks; done means PythonFunction bundles successfully with Poetry 2+ on Python 3.10.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, docker, python
- Domain
- build-system, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100