-
Notifications
You must be signed in to change notification settings - Fork 594
/
ServiceHealthCheckGracePeriodSeconds.py
58 lines (49 loc) · 2.04 KB
/
ServiceHealthCheckGracePeriodSeconds.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"""
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: MIT-0
"""
from __future__ import annotations
from typing import Any
import cfnlint.data.schemas.extensions.aws_ecs_service
from cfnlint.jsonschema import ValidationResult
from cfnlint.jsonschema.protocols import Validator
from cfnlint.rules.jsonschema.CfnLintJsonSchema import CfnLintJsonSchema, SchemaDetails
class ServiceHealthCheckGracePeriodSeconds(CfnLintJsonSchema):
id = "E3056"
shortdesc = (
"ECS service using HealthCheckGracePeriodSeconds "
"must also have LoadBalancers specified"
)
description = (
"When using a HealthCheckGracePeriodSeconds on an ECS "
"service, the service must also have a LoadBalancers specified "
"with at least one LoadBalancer in the array."
)
source_url = "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ecs-service.html#cfn-ecs-service-healthcheckgraceperiodseconds"
tags = ["properties", "ecs", "service", "container"]
def __init__(self) -> None:
super().__init__(
keywords=["Resources/AWS::ECS::Service/Properties"],
schema_details=SchemaDetails(
module=cfnlint.data.schemas.extensions.aws_ecs_service,
filename="healthcheckgraceperiodseconds.json",
),
all_matches=True,
)
def validate(
self, validator: Validator, keywords: Any, instance: Any, schema: dict[str, Any]
) -> ValidationResult:
cfn_validator = self.extend_validator(
validator=validator.evolve(
function_filter=validator.function_filter.evolve(
validate_dynamic_references=False,
add_cfn_lint_keyword=False,
)
),
schema=self._schema,
context=validator.context.evolve(
functions=["Fn::If", "Ref"],
strict_types=True,
),
)
yield from self._iter_errors(cfn_validator, instance)