forked from aws-cloudformation/cfn-lint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SnapStartEnabled.py
35 lines (27 loc) · 1.09 KB
/
SnapStartEnabled.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: MIT-0
"""
from collections import deque
from cfnlint.jsonschema import ValidationError
from cfnlint.rules import CloudFormationLintRule
class SnapStartEnabled(CloudFormationLintRule):
"""Check if the SnapStart is enabled for certain java runtimes"""
id = "I2530"
shortdesc = "Validate that SnapStart is configured for >= Java11 runtimes"
description = (
"SnapStart is a no-cost feature that can increase performance up to 10x. "
"Enable SnapStart for Java 11 and greater runtimes"
)
source_url = "https://docs.aws.amazon.com/lambda/latest/dg/snapstart.html"
tags = ["resources", "lambda"]
def validate(self, runtime):
if not isinstance(runtime, str):
return
if not (runtime.startswith("java")) or runtime in ["java8.al2", "java8"]:
return
yield ValidationError(
f"{runtime!r} runtime should consider using 'SnapStart'",
path=deque(["SnapStart", "ApplyOn"]),
rule=self,
)