Skip to content

Commit 912ef7b

Browse files
authored
Update Lambda deprecated runtimes (#594)
1 parent 7154248 commit 912ef7b

File tree

3 files changed

+32
-65
lines changed

3 files changed

+32
-65
lines changed

docs/rules/aws_lambda_function_deprecated_runtime.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# aws_lambda_function_deprecated_runtime
22

3-
Checks to see if a lambda function has been set with a runtime that is deprecated. This can show up as either "end of support" or "end of life" depending on the phase of deprecation it is currently in.
3+
Checks to see if a lambda function has been set with a runtime that is deprecated.
44

55
## Example
66

@@ -30,4 +30,4 @@ AWS no longer supports these runtimes.
3030

3131
## How To Fix
3232

33-
Update to a newer runtime. Supported runtimes can be found [here](https://docs.aws.amazon.com/lambda/latest/dg/runtime-support-policy.html)
33+
Update to a newer runtime. Supported runtimes can be found [here](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html)

rules/aws_lambda_function_deprecated_runtime.go

Lines changed: 30 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -13,51 +13,46 @@ import (
1313
type AwsLambdaFunctionDeprecatedRuntimeRule struct {
1414
tflint.DefaultRule
1515

16-
resourceType string
17-
attributeName string
18-
eosRuntimes map[string]time.Time
19-
eolRuntimes map[string]time.Time
16+
resourceType string
17+
attributeName string
18+
deprecatedRuntimes map[string]time.Time
2019

2120
Now time.Time
2221
}
2322

2423
// NewAwsLambdaFunctionDeprecatedRuntimeRule returns new rule with default attributes
2524
func NewAwsLambdaFunctionDeprecatedRuntimeRule() *AwsLambdaFunctionDeprecatedRuntimeRule {
25+
// @see https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html
2626
return &AwsLambdaFunctionDeprecatedRuntimeRule{
2727
resourceType: "aws_lambda_function",
2828
attributeName: "runtime",
29-
eosRuntimes: map[string]time.Time{
30-
"nodejs10.x": time.Date(2021, time.July, 30, 0, 0, 0, 0, time.UTC),
31-
"nodejs12.x": time.Date(2022, time.November, 14, 0, 0, 0, 0, time.UTC),
32-
"nodejs14.x": time.Date(2023, time.November, 27, 0, 0, 0, 0, time.UTC),
33-
"nodejs16.x": time.Date(2024, time.March, 11, 0, 0, 0, 0, time.UTC),
34-
"ruby2.5": time.Date(2021, time.July, 30, 0, 0, 0, 0, time.UTC),
35-
"ruby2.7": time.Date(2023, time.December, 7, 0, 0, 0, 0, time.UTC),
36-
"python2.7": time.Date(2021, time.July, 15, 0, 0, 0, 0, time.UTC),
37-
"python3.6": time.Date(2022, time.July, 18, 0, 0, 0, 0, time.UTC),
38-
"python3.7": time.Date(2023, time.November, 27, 0, 0, 0, 0, time.UTC),
39-
"dotnetcore2.1": time.Date(2021, time.September, 20, 0, 0, 0, 0, time.UTC),
40-
"dotnetcore3.1": time.Date(2023, time.January, 20, 0, 0, 0, 0, time.UTC),
41-
"dotnet7": time.Date(2024, time.May, 14, 0, 0, 0, 0, time.UTC),
42-
"java8": time.Date(2023, time.December, 31, 0, 0, 0, 0, time.UTC),
43-
"go1.x": time.Date(2023, time.December, 31, 0, 0, 0, 0, time.UTC),
44-
"provided": time.Date(2023, time.December, 31, 0, 0, 0, 0, time.UTC),
45-
},
46-
eolRuntimes: map[string]time.Time{
47-
"dotnetcore1.0": time.Date(2019, time.July, 30, 0, 0, 0, 0, time.UTC),
29+
deprecatedRuntimes: map[string]time.Time{
30+
"nodejs16.x": time.Date(2024, time.June, 12, 0, 0, 0, 0, time.UTC),
31+
"python3.8": time.Date(2024, time.October, 14, 0, 0, 0, 0, time.UTC),
32+
"java8": time.Date(2024, time.January, 8, 0, 0, 0, 0, time.UTC),
33+
"dotnet7": time.Date(2024, time.May, 14, 0, 0, 0, 0, time.UTC),
34+
"dotnet6": time.Date(2024, time.November, 12, 0, 0, 0, 0, time.UTC),
35+
"go1.x": time.Date(2024, time.January, 8, 0, 0, 0, 0, time.UTC),
36+
"provided": time.Date(2024, time.January, 8, 0, 0, 0, 0, time.UTC),
37+
// Already reached end of support
38+
"nodejs14.x": time.Date(2023, time.December, 4, 0, 0, 0, 0, time.UTC),
39+
"python3.7": time.Date(2023, time.December, 4, 0, 0, 0, 0, time.UTC),
40+
"ruby2.7": time.Date(2023, time.November, 27, 0, 0, 0, 0, time.UTC),
41+
"dotnetcore3.1": time.Date(2023, time.April, 3, 0, 0, 0, 0, time.UTC),
42+
"nodejs12.x": time.Date(2023, time.March, 31, 0, 0, 0, 0, time.UTC),
43+
"python3.6": time.Date(2022, time.July, 18, 0, 0, 0, 0, time.UTC),
44+
"dotnet5.0": time.Date(2022, time.May, 10, 0, 0, 0, 0, time.UTC),
45+
"dotnetcore2.1": time.Date(2022, time.January, 5, 0, 0, 0, 0, time.UTC),
46+
"nodejs10.x": time.Date(2021, time.July, 30, 0, 0, 0, 0, time.UTC),
47+
"ruby2.5": time.Date(2021, time.July, 30, 0, 0, 0, 0, time.UTC),
48+
"python2.7": time.Date(2021, time.July, 15, 0, 0, 0, 0, time.UTC),
49+
"nodejs8.10": time.Date(2020, time.March, 6, 0, 0, 0, 0, time.UTC),
50+
"nodejs4.3": time.Date(2020, time.March, 5, 0, 0, 0, 0, time.UTC),
51+
"nodejs4.3-edge": time.Date(2020, time.March, 5, 0, 0, 0, 0, time.UTC),
52+
"nodejs6.10": time.Date(2019, time.August, 12, 0, 0, 0, 0, time.UTC),
53+
"dotnetcore1.0": time.Date(2019, time.July, 27, 0, 0, 0, 0, time.UTC),
4854
"dotnetcore2.0": time.Date(2019, time.May, 30, 0, 0, 0, 0, time.UTC),
4955
"nodejs": time.Date(2016, time.October, 31, 0, 0, 0, 0, time.UTC),
50-
"nodejs4.3": time.Date(2020, time.March, 06, 0, 0, 0, 0, time.UTC),
51-
"nodejs4.3-edge": time.Date(2019, time.April, 30, 0, 0, 0, 0, time.UTC),
52-
"nodejs6.10": time.Date(2019, time.August, 12, 0, 0, 0, 0, time.UTC),
53-
"nodejs8.10": time.Date(2020, time.March, 06, 0, 0, 0, 0, time.UTC),
54-
"nodejs10.x": time.Date(2021, time.August, 30, 0, 0, 0, 0, time.UTC),
55-
"nodejs12.x": time.Date(2022, time.December, 14, 0, 0, 0, 0, time.UTC),
56-
"ruby2.5": time.Date(2021, time.August, 30, 0, 0, 0, 0, time.UTC),
57-
"python2.7": time.Date(2021, time.September, 30, 0, 0, 0, 0, time.UTC),
58-
"python3.6": time.Date(2022, time.August, 17, 0, 0, 0, 0, time.UTC),
59-
"dotnetcore2.1": time.Date(2021, time.October, 30, 0, 0, 0, 0, time.UTC),
60-
"dotnetcore3.1": time.Date(2023, time.February, 20, 0, 0, 0, 0, time.UTC),
6156
},
6257
Now: time.Now().UTC(),
6358
}
@@ -99,13 +94,7 @@ func (r *AwsLambdaFunctionDeprecatedRuntimeRule) Check(runner tflint.Runner) err
9994
}
10095

10196
err := runner.EvaluateExpr(attribute.Expr, func(val string) error {
102-
if _, ok := r.eolRuntimes[val]; ok && r.Now.After(r.eolRuntimes[val]) {
103-
runner.EmitIssue(
104-
r,
105-
fmt.Sprintf("The \"%s\" runtime has reached the end of life", val),
106-
attribute.Expr.Range(),
107-
)
108-
} else if _, ok := r.eosRuntimes[val]; ok && r.Now.After(r.eosRuntimes[val]) {
97+
if _, ok := r.deprecatedRuntimes[val]; ok && r.Now.After(r.deprecatedRuntimes[val]) {
10998
runner.EmitIssue(
11099
r,
111100
fmt.Sprintf("The \"%s\" runtime has reached the end of support", val),

rules/aws_lambda_function_deprecated_runtime_test.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -37,28 +37,6 @@ resource "aws_lambda_function" "function" {
3737
},
3838
},
3939
},
40-
{
41-
Name: "EOF",
42-
Content: `
43-
resource "aws_lambda_function" "function" {
44-
function_name = "test_function"
45-
role = "test_role"
46-
runtime = "nodejs10.x"
47-
}
48-
`,
49-
Now: time.Date(2021, time.September, 1, 0, 0, 0, 0, time.UTC),
50-
Expected: helper.Issues{
51-
{
52-
Rule: NewAwsLambdaFunctionDeprecatedRuntimeRule(),
53-
Message: "The \"nodejs10.x\" runtime has reached the end of life",
54-
Range: hcl.Range{
55-
Filename: "resource.tf",
56-
Start: hcl.Pos{Line: 5, Column: 12},
57-
End: hcl.Pos{Line: 5, Column: 24},
58-
},
59-
},
60-
},
61-
},
6240
{
6341
Name: "Live",
6442
Content: `

0 commit comments

Comments
 (0)