forked from aws-cloudformation/cfn-lint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSnapStartEnabled.py
41 lines (32 loc) · 1.22 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
36
37
38
39
40
41
"""
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: MIT-0
"""
from cfnlint.rules import CloudFormationLintRule, RuleMatch
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 __init__(self):
super().__init__()
self.resource_property_types.append("AWS::Lambda::Function")
def validate(self, runtime, path, region, regions):
if not isinstance(runtime, str):
return []
if region not in regions:
return []
if not (runtime.startswith("java")) or runtime in ["java8.al2", "java8"]:
return []
return [
RuleMatch(
path,
f"When using {runtime} configure SnapStart",
rule=self,
)
]