Skip to content

Commit

Permalink
Update Python versions for AWS lambda function
Browse files Browse the repository at this point in the history
Update the supported lambda runtimes for Python. The Python versions
3.12 and 3.13 are added. These versions are running on Amazon Linux
2023. According to the documentation, the glibc version is 2.34 on
this OS.

Remove the support of python3.8 that is deprecated since
Oct, 14 2024 and will be blocked on March, 2025.
  • Loading branch information
jeromef853 committed Dec 11, 2024
1 parent 95338b2 commit 4f49421
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
13 changes: 12 additions & 1 deletion src/e3/aws/troposphere/awslambda/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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,
Expand Down
21 changes: 16 additions & 5 deletions tests/tests_e3_aws/troposphere/awslambda/awslambda_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand All @@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit 4f49421

Please sign in to comment.