Skip to content
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
6 changes: 6 additions & 0 deletions localstack-core/localstack/services/lambda_/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@
DEPRECATED_RUNTIMES,
DEPRECATED_RUNTIMES_UPGRADES,
RUNTIMES_AGGREGATED,
SNAP_START_SUPPORTED_RUNTIMES,
VALID_RUNTIMES,
)
from localstack.services.lambda_.urlrouter import FunctionUrlRouter
Expand Down Expand Up @@ -718,6 +719,11 @@ def _validate_snapstart(snap_start: SnapStart, runtime: Runtime):
f"1 validation error detected: Value '{apply_on}' at 'snapStart.applyOn' failed to satisfy constraint: Member must satisfy enum value set: [PublishedVersions, None]"
)

if runtime not in SNAP_START_SUPPORTED_RUNTIMES:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍

raise InvalidParameterValueException(
f"{runtime} is not supported for SnapStart enabled functions.", Type="User"
)

def _validate_layers(self, new_layers: list[str], region: str, account_id: str):
if len(new_layers) > LAMBDA_LAYERS_LIMIT_PER_FUNCTION:
raise InvalidParameterValueException(
Expand Down
17 changes: 15 additions & 2 deletions localstack-core/localstack/services/lambda_/runtimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
Runtime.dotnet6: "dotnet:6",
Runtime.dotnetcore3_1: "dotnet:core3.1", # deprecated Apr 3, 2023 => Apr 3, 2023 => May 3, 2023
Runtime.go1_x: "go:1", # deprecated Jan 8, 2024 => Feb 8, 2024 => Mar 12, 2024
Runtime.ruby3_4: "ruby:3.4",
Runtime.ruby3_3: "ruby:3.3",
Runtime.ruby3_2: "ruby:3.2",
Runtime.ruby2_7: "ruby:2.7", # deprecated Dec 7, 2023 => Jan 9, 2024 => Feb 8, 2024
Expand Down Expand Up @@ -133,6 +134,7 @@
"ruby": [
Runtime.ruby3_2,
Runtime.ruby3_3,
Runtime.ruby3_4,
],
"dotnet": [
Runtime.dotnet6,
Expand All @@ -149,7 +151,18 @@
runtime for runtime_group in RUNTIMES_AGGREGATED.values() for runtime in runtime_group
]

# An unordered list of snapstart-enabled runtimes. Related to snapshots in test_snapstart_exceptions
# https://docs.aws.amazon.com/lambda/latest/dg/snapstart.html
SNAP_START_SUPPORTED_RUNTIMES = [
Runtime.java11,
Runtime.java17,
Runtime.java21,
Runtime.python3_12,
Runtime.python3_13,
Runtime.dotnet8,
]

# An ordered list of all Lambda runtimes considered valid by AWS. Matching snapshots in test_create_lambda_exceptions
VALID_RUNTIMES: str = "[nodejs20.x, provided.al2023, python3.12, python3.13, nodejs22.x, java17, nodejs16.x, dotnet8, python3.10, java11, python3.11, dotnet6, java21, nodejs18.x, provided.al2, ruby3.3, java8.al2, ruby3.2, python3.8, python3.9]"
VALID_RUNTIMES: str = "[nodejs20.x, provided.al2023, python3.12, python3.13, nodejs22.x, java17, nodejs16.x, dotnet8, python3.10, java11, python3.11, dotnet6, java21, nodejs18.x, provided.al2, ruby3.3, ruby3.4, java8.al2, ruby3.2, python3.8, python3.9]"
# An ordered list of all Lambda runtimes for layers considered valid by AWS. Matching snapshots in test_layer_exceptions
VALID_LAYER_RUNTIMES: str = "[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, nodejs22.x, python3.10, java8, nodejs12.x, python3.11, nodejs8.x, python3.12, nodejs14.x, nodejs8.9, python3.13, nodejs16.x, provided.al2, nodejs4.3-edge, nodejs18.x, ruby3.2, python3.4, ruby3.3, ruby2.5, python3.6, python2.7]"
VALID_LAYER_RUNTIMES: str = "[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, java25, java17, nodejs, nodejs4.3, java8.al2, go1.x, dotnet10, nodejs20.x, go1.9, byol, nodejs10.x, provided.al2023, nodejs22.x, python3.10, java8, nodejs12.x, python3.11, nodejs24.x, nodejs8.x, python3.12, nodejs14.x, nodejs8.9, python3.13, python3.14, nodejs16.x, provided.al2, nodejs4.3-edge, nodejs18.x, ruby3.2, python3.4, ruby3.3, ruby3.4, ruby2.5, python3.6, python2.7]"
9 changes: 4 additions & 5 deletions tests/aws/services/lambda_/test_lambda_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from localstack.services.lambda_.runtimes import (
ALL_RUNTIMES,
DEPRECATED_RUNTIMES,
SNAP_START_SUPPORTED_RUNTIMES,
)
from localstack.testing.aws.lambda_utils import (
_await_dynamodb_table_active,
Expand Down Expand Up @@ -6827,14 +6828,12 @@ def test_layer_deterministic_version(
class TestLambdaSnapStart:
@markers.aws.validated
@markers.lambda_runtime_update
@markers.multiruntime(scenario="echo")
@markers.multiruntime(scenario="echo", runtimes=SNAP_START_SUPPORTED_RUNTIMES)
def test_snapstart_lifecycle(self, multiruntime_lambda, snapshot, aws_client):
"""Test the API of the SnapStart feature. The optimization behavior is not supported in LocalStack.
Slow (~1-2min) against AWS.
"""
create_function_response = multiruntime_lambda.create_function(
MemorySize=1024, Timeout=5, SnapStart={"ApplyOn": "PublishedVersions"}
)
create_function_response = multiruntime_lambda.create_function(MemorySize=1024, Timeout=5)
function_name = create_function_response["FunctionName"]
snapshot.match("create_function_response", create_function_response)

Expand All @@ -6856,7 +6855,7 @@ def test_snapstart_lifecycle(self, multiruntime_lambda, snapshot, aws_client):

@markers.aws.validated
@markers.lambda_runtime_update
@markers.multiruntime(scenario="echo")
@markers.multiruntime(scenario="echo", runtimes=SNAP_START_SUPPORTED_RUNTIMES)
def test_snapstart_update_function_configuration(
self, multiruntime_lambda, snapshot, aws_client
):
Expand Down
Loading
Loading