Skip to content

Commit 75190c8

Browse files
authored
Update lambda runtime validation to new data (#3297)
1 parent ef52605 commit 75190c8

File tree

13 files changed

+244
-93
lines changed

13 files changed

+244
-93
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,128 @@
11
{
22
"dotnet6": {
3+
"create-block": "2025-02-28",
34
"deprecated": "2024-11-12",
4-
"eol": "2025-01-11",
5-
"successor": "dotnet8"
5+
"successor": "dotnet8",
6+
"update-block": "2025-05-31"
67
},
78
"dotnet7": {
9+
"create-block": "2024-05-14",
810
"deprecated": "2024-05-14",
9-
"eol": "2026-10-08",
10-
"successor": "dotnet8"
11+
"successor": "dotnet8",
12+
"update-block": "2024-05-14"
1113
},
1214
"dotnetcore1.0": {
13-
"deprecated": "2019-07-31",
14-
"eol": "2019-06-27",
15-
"successor": "dotnet8"
15+
"create-block": "2019-07-30",
16+
"deprecated": "2019-06-27",
17+
"successor": "dotnet8",
18+
"update-block": "2019-07-30"
1619
},
1720
"dotnetcore2.0": {
21+
"create-block": "2019-05-30",
1822
"deprecated": "2019-05-30",
19-
"eol": "2019-04-30",
20-
"successor": "dotnet8"
23+
"successor": "dotnet8",
24+
"update-block": "2019-05-30"
2125
},
2226
"dotnetcore2.1": {
23-
"deprecated": "2021-09-23",
24-
"eol": "2021-08-23",
25-
"successor": "dotnet8"
27+
"create-block": "2022-01-05",
28+
"deprecated": "2022-01-05",
29+
"successor": "dotnet8",
30+
"update-block": "2022-04-13"
2631
},
2732
"dotnetcore3.1": {
28-
"deprecated": "2023-02-20",
29-
"eol": "2023-01-20",
30-
"successor": "dotnet8"
33+
"create-block": "2023-04-03",
34+
"deprecated": "2023-04-03",
35+
"successor": "dotnet8",
36+
"update-block": "2023-05-03"
3137
},
3238
"nodejs": {
39+
"create-block": "2016-10-31",
3340
"deprecated": "2016-10-31",
34-
"eol": "2016-10-31",
35-
"successor": "nodejs20.x"
41+
"successor": "nodejs20.x",
42+
"update-block": "2016-10-31"
3643
},
3744
"nodejs10.x": {
38-
"deprecated": "2021-08-30",
39-
"eol": "2021-07-30",
40-
"successor": "nodejs20.x"
45+
"create-block": "2021-07-30",
46+
"deprecated": "2021-07-30",
47+
"successor": "nodejs20.x",
48+
"update-block": "2022-02-14"
4149
},
4250
"nodejs12.x": {
43-
"deprecated": "2022-12-14",
44-
"eol": "2022-11-14",
45-
"successor": "nodejs20.x"
51+
"create-block": "2023-03-31",
52+
"deprecated": "2023-03-31",
53+
"successor": "nodejs20.x",
54+
"update-block": "2023-04-30"
4655
},
4756
"nodejs14.x": {
57+
"create-block": "2024-07-09",
4858
"deprecated": "2023-12-04",
49-
"eol": "2024-01-09",
50-
"successor": "nodejs20.x"
59+
"successor": "nodejs20.x",
60+
"update-block": "2025-02-28"
5161
},
5262
"nodejs16.x": {
63+
"create-block": "2025-02-28",
5364
"deprecated": "2024-06-12",
54-
"eol": "2024-07-15",
55-
"successor": "nodejs20.x"
65+
"successor": "nodejs20.x",
66+
"update-block": "2025-03-31"
5667
},
5768
"nodejs4.3": {
58-
"deprecated": "2019-04-30",
59-
"eol": "2018-04-30",
60-
"successor": "nodejs20.x"
69+
"create-block": "2020-03-05",
70+
"deprecated": "2020-03-05",
71+
"successor": "nodejs20.x",
72+
"update-block": "2020-03-05"
6173
},
6274
"nodejs4.3-edge": {
63-
"deprecated": "2019-04-30",
64-
"eol": "2018-04-30",
65-
"successor": "nodejs20.x"
75+
"create-block": "2019-04-30",
76+
"deprecated": "2020-03-05",
77+
"successor": "nodejs20.x",
78+
"update-block": "2019-04-30"
6679
},
6780
"nodejs6.10": {
81+
"create-block": "2019-08-12",
6882
"deprecated": "2019-08-12",
69-
"eol": "2019-04-30",
70-
"successor": "nodejs20.x"
83+
"successor": "nodejs20.x",
84+
"update-block": "2019-08-12"
7185
},
7286
"nodejs8.10": {
73-
"deprecated": "2020-02-03",
74-
"eol": "2019-12-31",
75-
"successor": "nodejs20.x"
87+
"create-block": "2020-03-06",
88+
"deprecated": "2020-03-06",
89+
"successor": "nodejs20.x",
90+
"update-block": "2020-03-06"
7691
},
7792
"python2.7": {
78-
"deprecated": "2021-09-30",
79-
"eol": "2021-07-15",
80-
"successor": "python3.12"
93+
"create-block": "2021-07-15",
94+
"deprecated": "2021-07-15",
95+
"successor": "python3.12",
96+
"update-block": "2022-05-30"
8197
},
8298
"python3.6": {
83-
"deprecated": "2022-08-17",
84-
"eol": "2022-07-18",
85-
"successor": "python3.12"
99+
"create-block": "2022-07-18",
100+
"deprecated": "2022-07-18",
101+
"successor": "python3.12",
102+
"update-block": "2022-08-29"
86103
},
87104
"python3.7": {
105+
"create-block": "2024-01-09",
88106
"deprecated": "2023-12-04",
89-
"eol": "2024-01-09",
90-
"successor": "python3.12"
107+
"successor": "python3.12",
108+
"update-block": "2025-02-28"
91109
},
92110
"python3.8": {
111+
"create-block": "2025-02-28",
93112
"deprecated": "2024-10-14",
94-
"eol": "2024-11-13",
95-
"successor": "python3.12"
113+
"successor": "python3.12",
114+
"update-block": "2025-03-31"
96115
},
97116
"ruby2.5": {
117+
"create-block": "2021-07-30",
98118
"deprecated": "2021-07-30",
99-
"eol": "2021-07-30",
100-
"successor": "ruby3.2"
119+
"successor": "ruby3.2",
120+
"update-block": "2022-03-31"
101121
},
102122
"ruby2.7": {
123+
"create-block": "2024-01-09",
103124
"deprecated": "2023-12-07",
104-
"eol": "2024-01-09",
105-
"successor": "ruby3.2"
125+
"successor": "ruby3.2",
126+
"update-block": "2025-02-28"
106127
}
107128
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
"""
2+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
SPDX-License-Identifier: MIT-0
4+
"""
5+
6+
from datetime import datetime
7+
8+
from cfnlint.rules import RuleMatch
9+
from cfnlint.rules.resources.lmbd.DeprecatedRuntime import DeprecatedRuntime
10+
11+
12+
class DeprecatedRuntimeCreate(DeprecatedRuntime):
13+
"""Check if EOL Lambda Function Runtimes are used"""
14+
15+
id = "E2531"
16+
shortdesc = "Check if Lambda Function Runtimes are creatable"
17+
description = (
18+
"Check if an EOL Lambda Runtime is specified and you cannot create the function"
19+
)
20+
source_url = (
21+
"https://docs.aws.amazon.com/lambda/latest/dg/runtime-support-policy.html"
22+
)
23+
tags = ["resources", "lambda", "runtime"]
24+
25+
def check_runtime(self, runtime_value, path):
26+
"""Check if the given runtime is valid"""
27+
matches = []
28+
29+
runtime = self.deprecated_runtimes.get(runtime_value)
30+
if runtime:
31+
if (
32+
datetime.strptime(runtime["create-block"], "%Y-%m-%d")
33+
< self.current_date
34+
and datetime.strptime(runtime["update-block"], "%Y-%m-%d")
35+
> self.current_date
36+
):
37+
message = "Runtime ({0}) was deprecated on {1}. Creation disabled on {2} and update on {3}. Please consider updating to {3}"
38+
matches.append(
39+
RuleMatch(
40+
path,
41+
message.format(
42+
runtime_value,
43+
runtime["deprecated"],
44+
runtime["create-block"],
45+
runtime["update-block"],
46+
runtime["successor"],
47+
),
48+
)
49+
)
50+
return matches

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

+7-4
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,21 @@ def check_runtime(self, runtime_value, path):
2929
runtime = self.deprecated_runtimes.get(runtime_value)
3030
if runtime:
3131
if (
32-
datetime.strptime(runtime["eol"], "%Y-%m-%d") < self.current_date
33-
and datetime.strptime(runtime["deprecated"], "%Y-%m-%d")
32+
datetime.strptime(runtime["deprecated"], "%Y-%m-%d") < self.current_date
33+
and datetime.strptime(runtime["create-block"], "%Y-%m-%d")
34+
> self.current_date
35+
and datetime.strptime(runtime["update-block"], "%Y-%m-%d")
3436
> self.current_date
3537
):
36-
message = "EOL runtime ({0}) specified. Runtime is EOL since {1} and updating will be disabled at {2}. Please consider updating to {3}"
38+
message = "Runtime ({0}) was deprecated on {1}. Creation will be disabled on {2} and update on {3}. Please consider updating to {4}"
3739
matches.append(
3840
RuleMatch(
3941
path,
4042
message.format(
4143
runtime_value,
42-
runtime["eol"],
4344
runtime["deprecated"],
45+
runtime["create-block"],
46+
runtime["update-block"],
4447
runtime["successor"],
4548
),
4649
)

src/cfnlint/rules/resources/lmbd/DeprecatedRuntimeEnd.py renamed to src/cfnlint/rules/resources/lmbd/DeprecatedRuntimeUpdate.py

+13-7
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
from cfnlint.rules.resources.lmbd.DeprecatedRuntime import DeprecatedRuntime
1010

1111

12-
class DeprecatedRuntimeEnd(DeprecatedRuntime):
12+
class DeprecatedRuntimeUpdate(DeprecatedRuntime):
1313
"""Check if EOL Lambda Function Runtimes are used"""
1414

15-
id = "E2531"
16-
shortdesc = "Check if EOL Lambda Function Runtimes are used"
15+
id = "E2533"
16+
shortdesc = "Check if Lambda Function Runtimes are updatable"
1717
description = (
18-
"Check if an EOL Lambda Runtime is specified and give an error if used. "
18+
"Check if an EOL Lambda Runtime is specified and you cannot update the function"
1919
)
2020
source_url = (
2121
"https://docs.aws.amazon.com/lambda/latest/dg/runtime-support-policy.html"
@@ -28,13 +28,19 @@ def check_runtime(self, runtime_value, path):
2828

2929
runtime = self.deprecated_runtimes.get(runtime_value)
3030
if runtime:
31-
if datetime.strptime(runtime["deprecated"], "%Y-%m-%d") < self.current_date:
32-
message = "Deprecated runtime ({0}) specified. Updating disabled since {1}. Please consider updating to {2}"
31+
if (
32+
datetime.strptime(runtime["update-block"], "%Y-%m-%d")
33+
< self.current_date
34+
):
35+
message = "Runtime ({0}) was deprecated on {1}. Update disabled on {2}. Please consider updating to {3}"
3336
matches.append(
3437
RuleMatch(
3538
path,
3639
message.format(
37-
runtime_value, runtime["deprecated"], runtime["successor"]
40+
runtime_value,
41+
runtime["deprecated"],
42+
runtime["update-block"],
43+
runtime["successor"],
3844
),
3945
)
4046
)

test/fixtures/results/public/lambda-poller.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
"LineNumber": 151
1919
}
2020
},
21-
"Message": "Deprecated runtime (nodejs6.10) specified. Updating disabled since 2019-08-12. Please consider updating to nodejs20.x",
21+
"Message": "Runtime (nodejs6.10) was deprecated on 2019-08-12. Update disabled on 2019-08-12. Please consider updating to nodejs20.x",
2222
"Rule": {
23-
"Description": "Check if an EOL Lambda Runtime is specified and give an error if used. ",
24-
"Id": "E2531",
25-
"ShortDescription": "Check if EOL Lambda Function Runtimes are used",
23+
"Description": "Check if an EOL Lambda Runtime is specified and you cannot update the function",
24+
"Id": "E2533",
25+
"ShortDescription": "Check if Lambda Function Runtimes are updatable",
2626
"Source": "https://docs.aws.amazon.com/lambda/latest/dg/runtime-support-policy.html"
2727
}
2828
}

test/fixtures/results/quickstart/nist_config_rules.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@
7272
"LineNumber": 94
7373
}
7474
},
75-
"Message": "Deprecated runtime (nodejs) specified. Updating disabled since 2016-10-31. Please consider updating to nodejs20.x",
75+
"Message": "Runtime (nodejs) was deprecated on 2016-10-31. Update disabled on 2016-10-31. Please consider updating to nodejs20.x",
7676
"Rule": {
77-
"Description": "Check if an EOL Lambda Runtime is specified and give an error if used. ",
78-
"Id": "E2531",
79-
"ShortDescription": "Check if EOL Lambda Function Runtimes are used",
77+
"Description": "Check if an EOL Lambda Runtime is specified and you cannot update the function",
78+
"Id": "E2533",
79+
"ShortDescription": "Check if Lambda Function Runtimes are updatable",
8080
"Source": "https://docs.aws.amazon.com/lambda/latest/dg/runtime-support-policy.html"
8181
}
8282
},
@@ -152,11 +152,11 @@
152152
"LineNumber": 159
153153
}
154154
},
155-
"Message": "Deprecated runtime (nodejs) specified. Updating disabled since 2016-10-31. Please consider updating to nodejs20.x",
155+
"Message": "Runtime (nodejs) was deprecated on 2016-10-31. Update disabled on 2016-10-31. Please consider updating to nodejs20.x",
156156
"Rule": {
157-
"Description": "Check if an EOL Lambda Runtime is specified and give an error if used. ",
158-
"Id": "E2531",
159-
"ShortDescription": "Check if EOL Lambda Function Runtimes are used",
157+
"Description": "Check if an EOL Lambda Runtime is specified and you cannot update the function",
158+
"Id": "E2533",
159+
"ShortDescription": "Check if Lambda Function Runtimes are updatable",
160160
"Source": "https://docs.aws.amazon.com/lambda/latest/dg/runtime-support-policy.html"
161161
}
162162
},

test/fixtures/results/quickstart/nist_logging.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@
4343
"LineNumber": 44
4444
}
4545
},
46-
"Message": "Bucket cannot have ACLs set with ObjectOwnership's BucketOwnerEnforced setting",
46+
"Message": "A bucket with AccessControl set should also have OwnershipControl configured",
4747
"Rule": {
48-
"Description": "When using AccessControl other than private you must also configure OwnershipControls",
48+
"Description": "When using AccessControl other than private you must also configure OwnershipControls. The default is bucket owner enforced which disables ACLs.",
4949
"Id": "E3045",
5050
"ShortDescription": "Validate AccessControl are set with OwnershipControls",
5151
"Source": "https://docs.aws.amazon.com/AmazonS3/latest/userguide/about-object-ownership.html"

test/fixtures/templates/bad/resources/lambda/runtimes.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ Parameters:
66
myParameterRuntime:
77
Type: String
88
Description: Runtime
9-
Default: nodejs
9+
Default: python3.7
1010
AllowedValues:
1111
- nodejs10.x
12-
- nodejs
13-
- nodejs6.10
12+
- nodejs16.x
13+
- python3.7
1414
Resources:
1515
myLambdaExecutionRole:
1616
Type: AWS::IAM::Role

test/integration/test_good_templates.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,11 @@ class TestQuickStartTemplates(BaseCliTestCase):
149149
"Path": ["Resources", "myFunction", "Properties", "Runtime"],
150150
"Start": {"ColumnNumber": 3, "LineNumber": 10},
151151
},
152-
"Message": "Deprecated runtime (nodejs6.10) specified. Updating disabled since 2019-08-12. Please consider updating to nodejs20.x",
152+
"Message": "Runtime (nodejs6.10) was deprecated on 2019-08-12. Update disabled on 2019-08-12. Please consider updating to nodejs20.x",
153153
"Rule": {
154-
"Description": "Check if an EOL Lambda Runtime is specified and give an error if used. ",
155-
"Id": "E2531",
156-
"ShortDescription": "Check if EOL Lambda Function Runtimes are used",
154+
"Description": "Check if an EOL Lambda Runtime is specified and you cannot update the function",
155+
"Id": "E2533",
156+
"ShortDescription": "Check if Lambda Function Runtimes are updatable",
157157
"Source": "https://docs.aws.amazon.com/lambda/latest/dg/runtime-support-policy.html",
158158
},
159159
}

test/unit/rules/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,5 @@ def helper_file_negative(self, filename, err_count, regions=None):
6161
bad_runner = Runner(self.collection, filename, template, regions, [])
6262
bad_runner.transform()
6363
errs = bad_runner.run()
64+
print(errs)
6465
self.assertEqual(err_count, len(errs))

0 commit comments

Comments
 (0)