forked from aws-cloudformation/cfn-lint
-
Notifications
You must be signed in to change notification settings - Fork 2
/
DbClusterMultiAz.py
48 lines (40 loc) · 1.66 KB
/
DbClusterMultiAz.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
"""
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_rds_dbcluster
from cfnlint.jsonschema import ValidationResult, Validator
from cfnlint.rules.jsonschema.CfnLintJsonSchema import CfnLintJsonSchema, SchemaDetails
class DbClusterMultiAz(CfnLintJsonSchema):
id = "E3692"
shortdesc = "Validate Multi-AZ DB cluster configuration"
description = (
"When creating a Multi-AZ DB Cluster there are required fields and "
"the allowed values are different"
)
tags = ["resources"]
source_url = "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-rds-dbcluster.html#cfn-rds-dbcluster-engineversion"
def __init__(self) -> None:
super().__init__(
keywords=["Resources/AWS::RDS::DBCluster/Properties"],
schema_details=SchemaDetails(
module=cfnlint.data.schemas.extensions.aws_rds_dbcluster,
filename="multiaz.json",
),
all_matches=True,
)
# DBClusterInstanceClass is required
# AllocatedStorage is required
# Iops is required
def validate(
self, validator: Validator, keywords: Any, instance: Any, schema: dict[str, Any]
) -> ValidationResult:
for err in super().validate(validator, keywords, instance, schema):
if err.schema is False:
err.message = (
"Additional properties are not allowed "
f"{err.path[0]!r} when creating Multi-AZ cluster"
)
yield err