Skip to content

Commit 8f5129d

Browse files
authored
SnapStart is okay with new python dotnet (#3890)
* SnapStart is okay with new python dotnet
1 parent 700563c commit 8f5129d

File tree

2 files changed

+106
-7
lines changed

2 files changed

+106
-7
lines changed

src/cfnlint/rules/resources/lmbd/SnapStartSupported.py

+21-5
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,26 @@ def __init__(self):
5151
"sa-east-1",
5252
]
5353

54+
def _is_runtime_valid(self, runtime: str) -> bool:
55+
if not any(runtime.startswith(r) for r in ["python", "java", "dotnet"]):
56+
return False
57+
58+
if runtime.startswith("dotnetcore"):
59+
return False
60+
61+
return runtime not in [
62+
"dotnet5.0",
63+
"dotnet6",
64+
"dotnet7",
65+
"java8.al2",
66+
"java8",
67+
"python3.10",
68+
"python3.11",
69+
"python3.7",
70+
"python3.8",
71+
"python3.9",
72+
]
73+
5474
def validate(
5575
self, validator: Validator, _, instance: Any, schema: dict[str, Any]
5676
) -> ValidationResult:
@@ -94,11 +114,7 @@ def validate(
94114
if not isinstance(runtime, str):
95115
continue
96116

97-
if (
98-
runtime
99-
and (not runtime.startswith("java"))
100-
and runtime not in ["java8.al2", "java8"]
101-
):
117+
if not self._is_runtime_valid(runtime):
102118
yield ValidationError(
103119
f"{runtime!r} is not supported for 'SnapStart' enabled functions",
104120
path=deque(["SnapStart", "ApplyOn"]),

test/unit/rules/resources/lmbd/test_snapstart_supported.py

+85-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,90 @@ def rule():
6666
],
6767
),
6868
(
69-
"SnapStart not enabled on non java runtime",
69+
"SnapStart enabled for python3.12 error",
70+
{
71+
"Runtime": "python3.12",
72+
"SnapStart": {
73+
"ApplyOn": "PublishedVersions",
74+
},
75+
},
76+
["us-east-1"],
77+
True,
78+
False,
79+
[],
80+
),
81+
(
82+
"SnapStart enabled for dotnet",
83+
{
84+
"Runtime": "dotnet8",
85+
"SnapStart": {
86+
"ApplyOn": "PublishedVersions",
87+
},
88+
},
89+
["us-east-1"],
90+
True,
91+
False,
92+
[],
93+
),
94+
(
95+
"SnapStart enabled for go that isn't supported",
96+
{
97+
"Runtime": "go1.x",
98+
"SnapStart": {
99+
"ApplyOn": "PublishedVersions",
100+
},
101+
},
102+
["us-east-1"],
103+
True,
104+
False,
105+
[
106+
ValidationError(
107+
"'go1.x' is not supported for 'SnapStart' enabled functions",
108+
path=deque(["SnapStart", "ApplyOn"]),
109+
)
110+
],
111+
),
112+
(
113+
"SnapStart enabled for dotnet version that isn't supported",
114+
{
115+
"Runtime": "dotnet5.0",
116+
"SnapStart": {
117+
"ApplyOn": "PublishedVersions",
118+
},
119+
},
120+
["us-east-1"],
121+
True,
122+
False,
123+
[
124+
ValidationError(
125+
"'dotnet5.0' is not supported for 'SnapStart' enabled functions",
126+
path=deque(["SnapStart", "ApplyOn"]),
127+
)
128+
],
129+
),
130+
(
131+
"SnapStart enabled for dotnetcore version that isn't supported",
132+
{
133+
"Runtime": "dotnetcore2.1",
134+
"SnapStart": {
135+
"ApplyOn": "PublishedVersions",
136+
},
137+
},
138+
["us-east-1"],
139+
True,
140+
False,
141+
[
142+
ValidationError(
143+
(
144+
"'dotnetcore2.1' is not supported for "
145+
"'SnapStart' enabled functions"
146+
),
147+
path=deque(["SnapStart", "ApplyOn"]),
148+
)
149+
],
150+
),
151+
(
152+
"SnapStart not enabled on python non supported runtime",
70153
{
71154
"Runtime": "python3.11",
72155
},
@@ -76,7 +159,7 @@ def rule():
76159
[],
77160
),
78161
(
79-
"SnapStart not enabled on java runtime in a bad region",
162+
"SnapStart not enabled on python runtime in a bad region",
80163
{
81164
"Runtime": "python3.11",
82165
},

0 commit comments

Comments
 (0)