diff --git a/src/e3/aws/troposphere/awslambda/__init__.py b/src/e3/aws/troposphere/awslambda/__init__.py index a5dc2cf..e95157d 100644 --- a/src/e3/aws/troposphere/awslambda/__init__.py +++ b/src/e3/aws/troposphere/awslambda/__init__.py @@ -347,7 +347,8 @@ def resources(self, stack: Stack) -> list[AWSObject]: class PyFunction(Function): """Lambda with a Python runtime.""" - AMAZON_LINUX_2_RUNTIMES = ("3.8", "3.9", "3.10", "3.11") + AMAZON_LINUX_2_RUNTIMES = ("3.9", "3.10", "3.11") + AMAZON_LINUX_2023_RUNTIMES = ("3.12", "3.13") RUNTIME_CONFIGS = { f"python{version}": { "implementation": "cp", @@ -357,6 +358,16 @@ class PyFunction(Function): } for version in AMAZON_LINUX_2_RUNTIMES } + RUNTIME_CONFIGS.update( + { + f"python{version}": { + "implementation": "cp", + # Amazon Linux 2023 glibc version is 2.34 + "platforms": ("manylinux_2_34_x86_64",), + } + for version in AMAZON_LINUX_2023_RUNTIMES + } + ) def __init__( self, diff --git a/tests/tests_e3_aws/troposphere/awslambda/awslambda_test.py b/tests/tests_e3_aws/troposphere/awslambda/awslambda_test.py index 86473ec..423fd11 100644 --- a/tests/tests_e3_aws/troposphere/awslambda/awslambda_test.py +++ b/tests/tests_e3_aws/troposphere/awslambda/awslambda_test.py @@ -494,7 +494,19 @@ def test_pyfunction_with_dlconfig(stack: Stack) -> None: assert stack.export()["Resources"] == EXPECTED_PYFUNCTION_WITH_DLQ_TEMPLATE -def test_pyfunction_with_requirements(tmp_path: Path, stack: Stack) -> None: +@pytest.mark.parametrize( + "python_version, platform_list", + [ + ("3.9", ["manylinux_2_17_x86_64", "manylinux_2_24_x86_64"]), + ("3.10", ["manylinux_2_17_x86_64", "manylinux_2_24_x86_64"]), + ("3.11", ["manylinux_2_17_x86_64", "manylinux_2_24_x86_64"]), + ("3.12", ["manylinux_2_34_x86_64"]), + ("3.13", ["manylinux_2_34_x86_64"]), + ], +) +def test_pyfunction_with_requirements( + python_version: str, platform_list: list[str], tmp_path: Path, stack: Stack +) -> None: """Test PyFunction creation.""" stack.s3_bucket = "cfn_bucket" stack.s3_key = "templates/" @@ -506,7 +518,7 @@ def test_pyfunction_with_requirements(tmp_path: Path, stack: Stack) -> None: name="mypylambda", description="this is a test", role="somearn", - runtime="python3.11", + runtime=f"python{python_version}", code_dir=str(code_dir), handler="app.main", requirement_file="requirements.txt", @@ -518,9 +530,8 @@ def test_pyfunction_with_requirements(tmp_path: Path, stack: Stack) -> None: "-m", "pip", "install", - "--python-version=3.11", - "--platform=manylinux_2_17_x86_64", - "--platform=manylinux_2_24_x86_64", + f"--python-version={python_version}", + *(f"--platform={platform}" for platform in platform_list), "--implementation=cp", "--only-binary=:all:", "--target=dummy/Mypylambda/package",