(aws-lambda-python-alpha): bundling fails with latest poetry version (1.6.1) for python 3.8 runtime
Describe the bug
When cdk bundling of python lambda function (v3.8) is running, it's using image public.ecr.aws/sam/build-python3.8:latest and installs latest poetry version (atm v1.6.1). Poetry relies on requests (v2.26.0) which needs OpenSSL 1.1.1+ which is not installed with python version installed in building image (for build-python3.8:latest python version it's 3.8.17 with ssl version (1.0.2.11.15) OpenSSL 1.0.2k-fips).
Running any poetry command fails afterwards with error: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'OpenSSL 1.0.2k-fips 26 Jan 2017'. See: https://github.com/urllib3/urllib3/issues/2168
I tried dowgrade poetry version to 1.5.1 in docker image and it works just fine.
Expected Behavior
Bundling of python lambda function finishes successfully.
Current Behavior
Running any poetry command fails afterwards with error:
Traceback (most recent call last):
File "/usr/app/venv/bin/poetry", line 8, in <module>
sys.exit(main())
File "/usr/app/venv/lib/python3.8/site-packages/poetry/console/application.py", line 405, in main
exit_code: int = Application().run()
File "/usr/app/venv/lib/python3.8/site-packages/cleo/application.py", line 338, in run
self.render_error(e, io)
File "/usr/app/venv/lib/python3.8/site-packages/poetry/console/application.py", line 180, in render_error
self.set_solution_provider_repository(self._get_solution_provider_repository())
File "/usr/app/venv/lib/python3.8/site-packages/poetry/console/application.py", line 394, in _get_solution_provider_repository
from poetry.mixology.solutions.providers.python_requirement_solution_provider import ( # noqa: E501
File "/usr/app/venv/lib/python3.8/site-packages/poetry/mixology/solutions/providers/__init__.py", line 3, in <module>
from poetry.mixology.solutions.providers.python_requirement_solution_provider import (
File "/usr/app/venv/lib/python3.8/site-packages/poetry/mixology/solutions/providers/python_requirement_solution_provider.py", line 9, in <module>
from poetry.puzzle.exceptions import SolverProblemError
File "/usr/app/venv/lib/python3.8/site-packages/poetry/puzzle/__init__.py", line 3, in <module>
from poetry.puzzle.solver import Solver
File "/usr/app/venv/lib/python3.8/site-packages/poetry/puzzle/solver.py", line 16, in <module>
from poetry.puzzle.provider import Indicator
File "/usr/app/venv/lib/python3.8/site-packages/poetry/puzzle/provider.py", line 27, in <module>
from poetry.packages.direct_origin import DirectOrigin
File "/usr/app/venv/lib/python3.8/site-packages/poetry/packages/direct_origin.py", line 10, in <module>
from [poetry.inspection.info](http://poetry.inspection.info/) import PackageInfo
File "/usr/app/venv/lib/python3.8/site-packages/poetry/inspection/info.py", line 26, in <module>
from poetry.utils.env import EnvCommandError
File "/usr/app/venv/lib/python3.8/site-packages/poetry/utils/env/__init__.py", line 9, in <module>
from poetry.utils.env.base_env import Env
File "/usr/app/venv/lib/python3.8/site-packages/poetry/utils/env/base_env.py", line 18, in <module>
from poetry.utils.env.site_packages import SitePackages
File "/usr/app/venv/lib/python3.8/site-packages/poetry/utils/env/site_packages.py", line 11, in <module>
from poetry.utils.helpers import is_dir_writable
File "/usr/app/venv/lib/python3.8/site-packages/poetry/utils/helpers.py", line 17, in <module>
from requests.utils import atomic_open
File "/usr/app/venv/lib/python3.8/site-packages/requests/__init__.py", line 43, in <module>
import urllib3
File "/usr/app/venv/lib/python3.8/site-packages/urllib3/__init__.py", line 41, in <module>
raise ImportError(
ImportError: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'OpenSSL 1.0.2k-fips 26 Jan 2017'. See: https://github.com/urllib3/urllib3/issues/2168
Reproduction Steps
docker run -it --entrypoint bash public.ecr.aws/sam/build-python3.8:latestpip install poetrypoetry --version<- raises error
Check ssl version (inside docker container):
pythonimport ssl- print(ssl.OPENSSL_VERSION_INFO)
Possible Solution
Lock poetry version in public.ecr.aws/sam/build-python3.8:latest to 1.5.1
Additional Information/Context
These are steps which are running during bundling of a lambda function. In step 9/10 there's pip install pipenv==2022.4.8 poetry which installs latest poetry version
Status: Downloaded newer image for public.ecr.aws/sam/build-python3.8:latest
---> 864974b89a4d
Step 3/10 : ARG PIP_INDEX_URL
---> Running in e4a8bad32d70
Removing intermediate container e4a8bad32d70
---> 65c0895de72b
Step 4/10 : ARG PIP_EXTRA_INDEX_URL
---> Running in 935c581ccbc6
Removing intermediate container 935c581ccbc6
---> 9e1efa8c723a
Step 5/10 : ARG HTTPS_PROXY
---> Running in 745e5159eaf2
Removing intermediate container 745e5159eaf2
---> 8ac9e58be60d
Step 6/10 : ENV PATH="/usr/app/venv/bin:$PATH"
---> Running in c8bc054607fd
Removing intermediate container c8bc054607fd
---> 63760ccb60a8
Step 7/10 : ENV PIP_CACHE_DIR=/tmp/pip-cache
---> Running in 010adfa8952f
Removing intermediate container 010adfa8952f
---> e8ff5e52fb44
Step 8/10 : ENV POETRY_CACHE_DIR=/tmp/poetry-cache
---> Running in 3ca172f47052
Removing intermediate container 3ca172f47052
---> ad4fc100499c
Step 9/10 : RUN python -m venv /usr/app/venv && mkdir /tmp/pip-cache && chmod -R 777 /tmp/pip-cache && pip install --upgrade pip && mkdir /tmp/poetry-cache && chmod -R 777 /tmp/poetry-cache && pip install pipenv==2022.4.8 poetry && rm -rf /tmp/pip-cache/* /tmp/poetry-cache/*
---> Running in 73885fd6537d
Requirement already satisfied: pip in /usr/app/venv/lib/python3.8/site-packages (23.0.1)
Downloading tomlkit-0.12.1-py3-none-any.whl.metadata (2.7 kB)
Collecting trove-classifiers>=2022.5.19 (from poetry)
Obtaining dependency information for trove-classifiers>=2022.5.19 from https://files.pythonhosted.org/packages/14/c6/35e478a586e857c2a6d31fc7b1586d4ff965f729a290552b5c2eb7b9f807/trove_classifiers-2023.8.7-py3-none-any.whl.metadata
Downloading trove_classifiers-2023.8.7-py3-none-any.whl.metadata (2.2 kB)
Collecting msgpack>=0.5.2 (from cachecontrol[filecache]<0.14.0,>=0.13.0->poetry)
Downloading msgpack-1.0.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (322 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 322.4/322.4 kB 71.4 MB/s eta 0:00:00
Collecting filelock>=3.8.0 (from cachecontrol[filecache]<0.14.0,>=0.13.0->poetry)
Obtaining dependency information for filelock>=3.8.0 from https://files.pythonhosted.org/packages/00/45/ec3407adf6f6b5bf867a4462b2b0af27597a26bd3cd6e2534cb6ab029938/filelock-3.12.2-py3-none-any.whl.metadata
Downloading filelock-3.12.2-py3-none-any.whl.metadata (2.7 kB)
Collecting rapidfuzz<3.0.0,>=2.2.0 (from cleo<3.0.0,>=2.0.0->poetry)
Downloading rapidfuzz-2.15.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.0 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.0/3.0 MB 60.2 MB/s eta 0:00:00
Collecting urllib3>=1.25 (from dulwich<0.22.0,>=0.21.2->poetry)
Obtaining dependency information for urllib3>=1.25 from https://files.pythonhosted.org/packages/9b/81/62fd61001fa4b9d0df6e31d47ff49cfa9de4af03adecf339c7bc30656b37/urllib3-2.0.4-py3-none-any.whl.metadata
Downloading urllib3-2.0.4-py3-none-any.whl.metadata (6.6 kB)
Collecting zipp>=0.5 (from importlib-metadata>=4.4->poetry)
Obtaining dependency information for zipp>=0.5 from https://files.pythonhosted.org/packages/8c/08/d3006317aefe25ea79d3b76c9650afabaf6d63d1c8443b236e7405447503/zipp-3.16.2-py3-none-any.whl.metadata
Downloading zipp-3.16.2-py3-none-any.whl.metadata (3.7 kB)
Collecting attrs>=17.4.0 (from jsonschema<4.18.0,>=4.10.0->poetry)
Downloading attrs-23.1.0-py3-none-any.whl (61 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.2/61.2 kB 30.6 MB/s eta 0:00:00
Collecting importlib-resources>=1.4.0 (from jsonschema<4.18.0,>=4.10.0->poetry)
Obtaining dependency information for importlib-resources>=1.4.0 from https://files.pythonhosted.org/packages/25/d4/592f53ce2f8dde8be5720851bd0ab71cc2e76c55978e4163ef1ab7e389bb/importlib_resources-6.0.1-py3-none-any.whl.metadata
Downloading importlib_resources-6.0.1-py3-none-any.whl.metadata (4.0 kB)
Collecting pkgutil-resolve-name>=1.3.10 (from jsonschema<4.18.0,>=4.10.0->poetry)
Downloading pkgutil_resolve_name-1.3.10-py3-none-any.whl (4.7 kB)
Collecting pyrsistent!=0.17.0,!=0.17.1,!=0.17.2,>=0.14.0 (from jsonschema<4.18.0,>=4.10.0->poetry)
Downloading pyrsistent-0.19.3-py3-none-any.whl (57 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 57.5/57.5 kB 26.2 MB/s eta 0:00:00
Collecting jaraco.classes (from keyring<25.0.0,>=24.0.0->poetry)
Obtaining dependency information for jaraco.classes from https://files.pythonhosted.org/packages/c7/6b/1bc8fa93ea85146e08f0e0883bc579b7c7328364ed7df90b1628dcb36e10/jaraco.classes-3.3.0-py3-none-any.whl.metadata
Downloading jaraco.classes-3.3.0-py3-none-any.whl.metadata (2.9 kB)
Collecting SecretStorage>=3.2 (from keyring<25.0.0,>=24.0.0->poetry)
Downloading SecretStorage-3.3.3-py3-none-any.whl (15 kB)
Collecting jeepney>=0.4.2 (from keyring<25.0.0,>=24.0.0->poetry)
Downloading jeepney-0.8.0-py3-none-any.whl (48 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 48.4/48.4 kB 21.7 MB/s eta 0:00:00
Collecting ptyprocess>=0.5 (from pexpect<5.0.0,>=4.7.0->poetry)
Downloading ptyprocess-0.7.0-py2.py3-none-any.whl (13 kB)
Collecting charset-normalizer<4,>=2 (from requests<3.0,>=2.26->poetry)
Obtaining dependency information for charset-normalizer<4,>=2 from https://files.pythonhosted.org/packages/cb/e7/5e43745003bf1f90668c7be23fc5952b3a2b9c2558f16749411c18039b36/charset_normalizer-3.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata
Downloading charset_normalizer-3.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (31 kB)
Collecting idna<4,>=2.5 (from requests<3.0,>=2.26->poetry)
Downloading idna-3.4-py3-none-any.whl (61 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.5/61.5 kB 29.8 MB/s eta 0:00:00
Collecting distlib<1,>=0.3.7 (from virtualenv->pipenv==2022.4.8)
Obtaining dependency information for distlib<1,>=0.3.7 from https://files.pythonhosted.org/packages/43/a0/9ba967fdbd55293bacfc1507f58e316f740a3b231fc00e3d86dc39bc185a/distlib-0.3.7-py2.py3-none-any.whl.metadata
Downloading distlib-0.3.7-py2.py3-none-any.whl.metadata (5.1 kB)
Collecting cryptography>=2.0 (from SecretStorage>=3.2->keyring<25.0.0,>=24.0.0->poetry)
Obtaining dependency information for cryptography>=2.0 from https://files.pythonhosted.org/packages/21/74/a7ebb5bcf733b1626e4778941e505792d7f655e799ff3bdbd9a176516ee2/cryptography-41.0.3-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata
Downloading cryptography-41.0.3-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (5.2 kB)
Collecting more-itertools (from jaraco.classes->keyring<25.0.0,>=24.0.0->poetry)
Obtaining dependency information for more-itertools from https://files.pythonhosted.org/packages/5a/cb/6dce742ea14e47d6f565589e859ad225f2a5de576d7696e0623b784e226b/more_itertools-10.1.0-py3-none-any.whl.metadata
Downloading more_itertools-10.1.0-py3-none-any.whl.metadata (33 kB)
Collecting cffi>=1.12 (from cryptography>=2.0->SecretStorage>=3.2->keyring<25.0.0,>=24.0.0->poetry)
Downloading cffi-1.15.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (442 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 442.7/442.7 kB 68.4 MB/s eta 0:00:00
Collecting pycparser (from cffi>=1.12->cryptography>=2.0->SecretStorage>=3.2->keyring<25.0.0,>=24.0.0->poetry)
Downloading pycparser-2.21-py2.py3-none-any.whl (118 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 118.7/118.7 kB 50.4 MB/s eta 0:00:00
Downloading poetry-1.6.1-py3-none-any.whl (232 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 232.8/232.8 kB 60.6 MB/s eta 0:00:00
Downloading poetry_core-1.7.0-py3-none-any.whl (426 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 426.4/426.4 kB 83.0 MB/s eta 0:00:00
Downloading importlib_metadata-6.8.0-py3-none-any.whl (22 kB)
Downloading keyring-24.2.0-py3-none-any.whl (37 kB)
Downloading platformdirs-3.10.0-py3-none-any.whl (17 kB)
Downloading poetry_plugin_export-1.5.0-py3-none-any.whl (10 kB)
Downloading requests-2.31.0-py3-none-any.whl (62 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.6/62.6 kB 28.2 MB/s eta 0:00:00
Downloading certifi-2023.7.22-py3-none-any.whl (158 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 158.3/158.3 kB 49.6 MB/s eta 0:00:00
Downloading shellingham-1.5.3-py2.py3-none-any.whl (9.7 kB)
Downloading tomlkit-0.12.1-py3-none-any.whl (37 kB)
Downloading trove_classifiers-2023.8.7-py3-none-any.whl (13 kB)
Downloading virtualenv-20.24.3-py3-none-any.whl (3.0 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.0/3.0 MB 98.6 MB/s eta 0:00:00
Downloading charset_normalizer-3.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (199 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 199.1/199.1 kB 46.1 MB/s eta 0:00:00
Downloading distlib-0.3.7-py2.py3-none-any.whl (468 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 468.9/468.9 kB 92.3 MB/s eta 0:00:00
Downloading filelock-3.12.2-py3-none-any.whl (10 kB)
Downloading importlib_resources-6.0.1-py3-none-any.whl (34 kB)
Downloading urllib3-2.0.4-py3-none-any.whl (123 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 123.9/123.9 kB 50.7 MB/s eta 0:00:00
Downloading zipp-3.16.2-py3-none-any.whl (7.2 kB)
Downloading cachecontrol-0.13.1-py3-none-any.whl (22 kB)
Downloading jaraco.classes-3.3.0-py3-none-any.whl (5.9 kB)
Downloading cryptography-41.0.3-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.3 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.3/4.3 MB 77.0 MB/s eta 0:00:00
Downloading more_itertools-10.1.0-py3-none-any.whl (55 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 55.8/55.8 kB 27.4 MB/s eta 0:00:00
Installing collected packages: trove-classifiers, ptyprocess, msgpack, distlib, zipp, virtualenv-clone, urllib3, tomlkit, tomli, shellingham, rapidfuzz, pyrsistent, pycparser, poetry-core, platformdirs, pkgutil-resolve-name, pkginfo, pexpect, packaging, more-itertools, jeepney, installer, idna, filelock, crashtest, charset-normalizer, certifi, attrs, virtualenv, requests, pyproject-hooks, jaraco.classes, importlib-resources, importlib-metadata, dulwich, cleo, cffi, requests-toolbelt, pipenv, jsonschema, cryptography, cachecontrol, build, SecretStorage, keyring, poetry-plugin-export, poetry
Successfully installed SecretStorage-3.3.3 attrs-23.1.0 build-0.10.0 cachecontrol-0.13.1 certifi-2023.7.22 cffi-1.15.1 charset-normalizer-3.2.0 cleo-2.0.1 crashtest-0.4.1 cryptography-41.0.3 distlib-0.3.7 dulwich-0.21.5 filelock-3.12.2 idna-3.4 importlib-metadata-6.8.0 importlib-resources-6.0.1 installer-0.7.0 jaraco.classes-3.3.0 jeepney-0.8.0 jsonschema-4.17.3 keyring-24.2.0 more-itertools-10.1.0 msgpack-1.0.5 packaging-23.1 pexpect-4.8.0 pipenv-2022.4.8 pkginfo-1.9.6 pkgutil-resolve-name-1.3.10 platformdirs-3.10.0 poetry-1.6.1 poetry-core-1.7.0 poetry-plugin-export-1.5.0 ptyprocess-0.7.0 pycparser-2.21 pyproject-hooks-1.0.0 pyrsistent-0.19.3 rapidfuzz-2.15.1 requests-2.31.0 requests-toolbelt-1.0.0 shellingham-1.5.3 tomli-2.0.1 tomlkit-0.12.1 trove-classifiers-2023.8.7 urllib3-2.0.4 virtualenv-20.24.3 virtualenv-clone-0.5.7 zipp-3.16.2
Removing intermediate container 73885fd6537d
---> 34305d0e3bd0
Step 10/10 : CMD [ "python" ]
---> Running in df31ce8dcd78
Removing intermediate container df31ce8dcd78
---> 7374fa60644f
Successfully built 7374fa60644f
CDK CLI Version
2.81.0 (build bd920f2)
Framework Version
2.78.0
Node.js Version
v18.1.0
OS
Windows 10 with WSL Ubuntu-20.04
Language
Python
Language Version
Python (3.8.10)
Other information
There's also nothing special about cdk code in project where I discovered it:
import aws_cdk.aws_lambda_python_alpha as aws_lambda
self._lambda_function = aws_lambda.PythonFunction(
self,
"MyLambda",
runtime=Runtime.PYTHON_3_8,
entry=path_to_python_function,
description=description,
timeout=timeout,
environment=environment,
memory_size=memory_size,
)
pyproject.toml
[tool.poetry.dependencies]
python = "^3.8"
aws-cdk-lib = "^2.43.0"
"aws-cdk.aws-lambda-python-alpha" = "^2.43.0a0"
constructs = "^10.0.0"
poetry.lock
...
[[package]]
name = "aws-cdk-lib"
version = "2.78.0"
description = "Version 2 of the AWS Cloud Development Kit library"
category = "main"
optional = false
python-versions = "~=3.7"
files = [
{file = "aws-cdk-lib-2.78.0.tar.gz", hash = "sha256:f258a686a86f341f84070baa6d60e578c9acf3fa17d1408c17dde2ba0385c0da"},
{file = "aws_cdk_lib-2.78.0-py3-none-any.whl", hash = "sha256:977e572bbdfa13e0ba1720d69ef45c69d8179b40c3db806bdb1710391c7e59e4"},
]
...
[[package]]
name = "aws-cdk.aws-lambda-python-alpha"
version = "2.43.1a0"
description = "The CDK Construct Library for AWS Lambda in Python"
category = "main"
optional = false
python-versions = "~=3.7"
files = [
{file = "aws-cdk.aws-lambda-python-alpha-2.43.1a0.tar.gz", hash = "sha256:289b12d85f83fcedb524f26cb6e01b97503aab0c8c52bf45c17e27767486aeff"},
{file = "aws_cdk.aws_lambda_python_alpha-2.43.1a0-py3-none-any.whl", hash = "sha256:367875cd031378ea9a1ac7bfd224a6cf97de15ddbbfc7e8f8ae5e2b9bf551378"},
]
...
Thanks for your report.
Are you able to report this to https://github.com/aws/aws-sam-build-images/issues and link back to this issue? Looks like this should be fixed from the upstream.
According to this https://github.com/aws/aws-cdk/blob/ed00f245159fe06f19f40569ca97183d8292fdf5/packages/%40aws-cdk/aws-lambda-python-alpha/lib/Dockerfile#L3
And this
https://github.com/aws/aws-cdk/blob/ed00f245159fe06f19f40569ca97183d8292fdf5/packages/%40aws-cdk/aws-lambda-python-alpha/lib/bundling.ts#L100-L106
I think before it is fixed from the upstream, we should be allowed to specify custom docker image label or custom DockerImage to work it around?
I think before it is fixed from the upstream, we should be allowed to specify custom docker image label or custom
DockerImageto work it around?
Can you give more detail on how we would specify a custom DockerImage? We have run into the same difficulties as OP while using codepipeline - synth is failing and the issue seems 'deeper' than we can touch
@igorsimko good news. This was fixed in #26823 for aws-lambda-python-alpha. It was included in our most recent release (2.93.0). Downgrading to poetry 1.5.1 was the solution.
⚠️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.