Add new lambda runtimes and more parity fixes by joe4dev · Pull Request #9697 · localstack/localstack · GitHub
Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion localstack/config.py
37 changes: 5 additions & 32 deletions localstack/services/lambda_/api_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
LayerVersionContentOutput,
PublishLayerVersionResponse,
ResourceNotFoundException,
Runtime,
TracingConfig,
VpcConfigResponse,
)
from localstack.services.lambda_.runtimes import ALL_RUNTIMES, VALID_LAYER_RUNTIMES, VALID_RUNTIMES
from localstack.utils.collections import merge_recursive

if TYPE_CHECKING:
Expand Down Expand Up @@ -92,31 +92,6 @@
# Date format as returned by the lambda service
LAMBDA_DATE_FORMAT = "%Y-%m-%dT%H:%M:%S.%f+0000"

# An unordered list of all Lambda runtimes supported by LocalStack.
# Has to contain all elements of lambda_mapping.IMAGE_MAPPING.
RUNTIMES = [
Runtime.nodejs12_x,
Runtime.nodejs14_x,
Runtime.nodejs16_x,
Runtime.nodejs18_x,
Runtime.python3_7,
Runtime.python3_8,
Runtime.python3_9,
Runtime.python3_10,
Runtime.python3_11,
Runtime.ruby2_7,
Runtime.ruby3_2,
Runtime.java8,
Runtime.java8_al2,
Runtime.java11,
Runtime.java17,
Runtime.dotnetcore3_1,
Runtime.dotnet6,
Runtime.go1_x,
Runtime.provided,
Runtime.provided_al2,
]

# An unordered list of all Lambda CPU architectures supported by LocalStack.
ARCHITECTURES = [Architecture.arm64, Architecture.x86_64]

Expand Down Expand Up @@ -609,11 +584,9 @@ def parse_layer_arn(layer_version_arn: str) -> Tuple[str, str, str, str]:
)


# TODO: use list of valid runtimes from botocore through validators. See:
# https://github.com/localstack/localstack/pull/7675#discussion_r1107777058
def validate_layer_runtime(compatible_runtime: str) -> str | None:
if compatible_runtime is not None and compatible_runtime not in RUNTIMES:
return f"Value '{compatible_runtime}' at 'compatibleRuntime' failed to satisfy constraint: Member must satisfy enum value set: [ruby2.6, dotnetcore1.0, python3.7, nodejs8.10, nasa, ruby2.7, python2.7-greengrass, dotnetcore2.0, python3.8, java21, dotnet6, dotnetcore2.1, python3.9, java11, nodejs6.10, provided, dotnetcore3.1, dotnet8, java17, nodejs, nodejs4.3, java8.al2, go1.x, nodejs20.x, go1.9, byol, nodejs10.x, provided.al2023, python3.10, java8, nodejs12.x, python3.11, nodejs8.x, python3.12, nodejs14.x, nodejs8.9, nodejs16.x, provided.al2, nodejs4.3-edge, nodejs18.x, ruby3.2, python3.4, ruby2.5, python3.6, python2.7]"
if compatible_runtime is not None and compatible_runtime not in ALL_RUNTIMES:
return f"Value '{compatible_runtime}' at 'compatibleRuntime' failed to satisfy constraint: Member must satisfy enum value set: {VALID_LAYER_RUNTIMES}"
return None


Expand All @@ -628,8 +601,8 @@ def validate_layer_runtimes_and_architectures(
):
validations = []

if compatible_runtimes and set(compatible_runtimes).difference(RUNTIMES):
constraint = "Member must satisfy enum value set: [java17, provided, nodejs16.x, nodejs14.x, ruby2.7, python3.10, java11, python3.11, dotnet6, go1.x, nodejs18.x, provided.al2, java8, java8.al2, ruby3.2, python3.7, python3.8, python3.9]"
if compatible_runtimes and set(compatible_runtimes).difference(ALL_RUNTIMES):
constraint = f"Member must satisfy enum value set: {VALID_RUNTIMES}"
validation_msg = f"Value '[{', '.join([s for s in compatible_runtimes])}]' at 'compatibleRuntimes' failed to satisfy constraint: {constraint}"
validations.append(validation_msg)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
INVOCATION_PORT,
ExecutorEndpoint,
)
from localstack.services.lambda_.invocation.lambda_models import IMAGE_MAPPING, FunctionVersion
from localstack.services.lambda_.invocation.lambda_models import FunctionVersion
from localstack.services.lambda_.invocation.runtime_executor import (
LambdaRuntimeException,
RuntimeExecutor,
Expand All @@ -24,6 +24,7 @@
get_main_endpoint_from_container,
)
from localstack.services.lambda_.packages import lambda_runtime_package
from localstack.services.lambda_.runtimes import IMAGE_MAPPING
from localstack.utils.container_networking import get_main_container_name
from localstack.utils.container_utils.container_client import (
ContainerConfiguration,
Expand Down
25 changes: 0 additions & 25 deletions localstack/services/lambda_/invocation/lambda_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,31 +42,6 @@

LOG = logging.getLogger(__name__)

# To add support for a new runtime, just add it here with the accompanying image postfix and to api_utils.RUNTIMES
IMAGE_MAPPING = {
"python3.7": "python:3.7",
"python3.8": "python:3.8",
"python3.9": "python:3.9",
"python3.10": "python:3.10",
"python3.11": "python:3.11",
"nodejs12.x": "nodejs:12",
"nodejs14.x": "nodejs:14",
"nodejs16.x": "nodejs:16",
"nodejs18.x": "nodejs:18",
"ruby2.7": "ruby:2.7",
"ruby3.2": "ruby:3.2",
"java8": "java:8",
"java8.al2": "java:8.al2",
"java11": "java:11",
"java17": "java:17",
"dotnetcore3.1": "dotnet:core3.1",
"dotnet6": "dotnet:6",
"go1.x": "go:1",
"provided": "provided:alami",
"provided.al2": "provided:al2",
}
SNAP_START_SUPPORTED_RUNTIMES = [Runtime.java11, Runtime.java17]


# TODO: maybe we should make this more "transient" by always initializing to Pending and *not* persisting it?
@dataclasses.dataclass(frozen=True)
Expand Down
94 changes: 51 additions & 43 deletions localstack/services/lambda_/provider.py
Loading