Skip to content

Commit 9383d50

Browse files
authored
Lambda: Added Ruby 3.4 Runtime (#12458)
1 parent a6be285 commit 9383d50

File tree

7 files changed

+736
-3883
lines changed

7 files changed

+736
-3883
lines changed

localstack-core/localstack/services/lambda_/provider.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@
223223
DEPRECATED_RUNTIMES,
224224
DEPRECATED_RUNTIMES_UPGRADES,
225225
RUNTIMES_AGGREGATED,
226+
SNAP_START_SUPPORTED_RUNTIMES,
226227
VALID_RUNTIMES,
227228
)
228229
from localstack.services.lambda_.urlrouter import FunctionUrlRouter
@@ -718,6 +719,11 @@ def _validate_snapstart(snap_start: SnapStart, runtime: Runtime):
718719
f"1 validation error detected: Value '{apply_on}' at 'snapStart.applyOn' failed to satisfy constraint: Member must satisfy enum value set: [PublishedVersions, None]"
719720
)
720721

722+
if runtime not in SNAP_START_SUPPORTED_RUNTIMES:
723+
raise InvalidParameterValueException(
724+
f"{runtime} is not supported for SnapStart enabled functions.", Type="User"
725+
)
726+
721727
def _validate_layers(self, new_layers: list[str], region: str, account_id: str):
722728
if len(new_layers) > LAMBDA_LAYERS_LIMIT_PER_FUNCTION:
723729
raise InvalidParameterValueException(

localstack-core/localstack/services/lambda_/runtimes.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
Runtime.dotnet6: "dotnet:6",
6060
Runtime.dotnetcore3_1: "dotnet:core3.1", # deprecated Apr 3, 2023 => Apr 3, 2023 => May 3, 2023
6161
Runtime.go1_x: "go:1", # deprecated Jan 8, 2024 => Feb 8, 2024 => Mar 12, 2024
62+
Runtime.ruby3_4: "ruby:3.4",
6263
Runtime.ruby3_3: "ruby:3.3",
6364
Runtime.ruby3_2: "ruby:3.2",
6465
Runtime.ruby2_7: "ruby:2.7", # deprecated Dec 7, 2023 => Jan 9, 2024 => Feb 8, 2024
@@ -133,6 +134,7 @@
133134
"ruby": [
134135
Runtime.ruby3_2,
135136
Runtime.ruby3_3,
137+
Runtime.ruby3_4,
136138
],
137139
"dotnet": [
138140
Runtime.dotnet6,
@@ -149,7 +151,18 @@
149151
runtime for runtime_group in RUNTIMES_AGGREGATED.values() for runtime in runtime_group
150152
]
151153

154+
# An unordered list of snapstart-enabled runtimes. Related to snapshots in test_snapstart_exceptions
155+
# https://docs.aws.amazon.com/lambda/latest/dg/snapstart.html
156+
SNAP_START_SUPPORTED_RUNTIMES = [
157+
Runtime.java11,
158+
Runtime.java17,
159+
Runtime.java21,
160+
Runtime.python3_12,
161+
Runtime.python3_13,
162+
Runtime.dotnet8,
163+
]
164+
152165
# An ordered list of all Lambda runtimes considered valid by AWS. Matching snapshots in test_create_lambda_exceptions
153-
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]"
166+
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]"
154167
# An ordered list of all Lambda runtimes for layers considered valid by AWS. Matching snapshots in test_layer_exceptions
155-
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]"
168+
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]"

tests/aws/services/lambda_/test_lambda_api.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
from localstack.services.lambda_.runtimes import (
3939
ALL_RUNTIMES,
4040
DEPRECATED_RUNTIMES,
41+
SNAP_START_SUPPORTED_RUNTIMES,
4142
)
4243
from localstack.testing.aws.lambda_utils import (
4344
_await_dynamodb_table_active,
@@ -6827,14 +6828,12 @@ def test_layer_deterministic_version(
68276828
class TestLambdaSnapStart:
68286829
@markers.aws.validated
68296830
@markers.lambda_runtime_update
6830-
@markers.multiruntime(scenario="echo")
6831+
@markers.multiruntime(scenario="echo", runtimes=SNAP_START_SUPPORTED_RUNTIMES)
68316832
def test_snapstart_lifecycle(self, multiruntime_lambda, snapshot, aws_client):
68326833
"""Test the API of the SnapStart feature. The optimization behavior is not supported in LocalStack.
68336834
Slow (~1-2min) against AWS.
68346835
"""
6835-
create_function_response = multiruntime_lambda.create_function(
6836-
MemorySize=1024, Timeout=5, SnapStart={"ApplyOn": "PublishedVersions"}
6837-
)
6836+
create_function_response = multiruntime_lambda.create_function(MemorySize=1024, Timeout=5)
68386837
function_name = create_function_response["FunctionName"]
68396838
snapshot.match("create_function_response", create_function_response)
68406839

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

68576856
@markers.aws.validated
68586857
@markers.lambda_runtime_update
6859-
@markers.multiruntime(scenario="echo")
6858+
@markers.multiruntime(scenario="echo", runtimes=SNAP_START_SUPPORTED_RUNTIMES)
68606859
def test_snapstart_update_function_configuration(
68616860
self, multiruntime_lambda, snapshot, aws_client
68626861
):

0 commit comments

Comments
 (0)