Skip to content

Commit b1aec84

Browse files
authored
Read cached ValueTypes from us-east-1 (#2628)
1 parent 808ebec commit b1aec84

File tree

5 files changed

+48
-11
lines changed

5 files changed

+48
-11
lines changed

src/cfnlint/rules/parameters/AllowedPattern.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,24 @@ def check(self, cfn, properties, value_specs, property_specs, path):
126126
property_type = (
127127
property_specs.get("Properties").get(prop).get("Type")
128128
)
129+
value_specs = (
130+
RESOURCE_SPECS.get(cfn.regions[0])
131+
.get("ValueTypes")
132+
.get(value_type, {})
133+
)
134+
if value_specs == "CACHED":
135+
value_specs = (
136+
RESOURCE_SPECS.get("us-east-1")
137+
.get("ValueTypes")
138+
.get(value_type, {})
139+
)
129140
matches.extend(
130141
cfn.check_value(
131142
p_value,
132143
prop,
133144
p_path,
134145
check_ref=self.check_value_ref,
135-
value_specs=RESOURCE_SPECS.get(cfn.regions[0])
136-
.get("ValueTypes")
137-
.get(value_type, {}),
146+
value_specs=value_specs,
138147
cfn=cfn,
139148
property_type=property_type,
140149
property_name=prop,

src/cfnlint/rules/resources/properties/AllowedPattern.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,24 @@ def check(self, cfn, properties, value_specs, property_specs, path):
9393
property_type = (
9494
property_specs.get("Properties").get(prop).get("Type")
9595
)
96+
value_specs = (
97+
RESOURCE_SPECS.get(cfn.regions[0])
98+
.get("ValueTypes")
99+
.get(value_type, {})
100+
)
101+
if value_specs == "CACHED":
102+
value_specs = (
103+
RESOURCE_SPECS.get("us-east-1")
104+
.get("ValueTypes")
105+
.get(value_type, {})
106+
)
96107
matches.extend(
97108
cfn.check_value(
98109
p_value,
99110
prop,
100111
p_path,
101112
check_value=self.check_value,
102-
value_specs=RESOURCE_SPECS.get(cfn.regions[0])
103-
.get("ValueTypes")
104-
.get(value_type, {}),
113+
value_specs=value_specs,
105114
cfn=cfn,
106115
property_type=property_type,
107116
property_name=prop,

src/cfnlint/rules/resources/properties/AllowedValue.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ def initialize(self, cfn):
3131
def check_value(self, value, path, property_name, **kwargs):
3232
"""Check Value"""
3333
matches = []
34-
3534
allowed_value_specs = kwargs.get("value_specs", {}).get("AllowedValues", {})
3635

3736
if allowed_value_specs:
@@ -62,15 +61,24 @@ def check(self, cfn, properties, value_specs, property_specs, path):
6261
property_type = (
6362
property_specs.get("Properties").get(prop).get("Type")
6463
)
64+
value_type_details = (
65+
RESOURCE_SPECS.get(cfn.regions[0])
66+
.get("ValueTypes")
67+
.get(value_type, {})
68+
)
69+
if value_type_details == "CACHED":
70+
value_type_details = (
71+
RESOURCE_SPECS.get("us-east-1")
72+
.get("ValueTypes")
73+
.get(value_type, {})
74+
)
6575
matches.extend(
6676
cfn.check_value(
6777
p_value,
6878
prop,
6979
p_path,
7080
check_value=self.check_value,
71-
value_specs=RESOURCE_SPECS.get(cfn.regions[0])
72-
.get("ValueTypes")
73-
.get(value_type, {}),
81+
value_specs=value_type_details,
7482
cfn=cfn,
7583
property_type=property_type,
7684
property_name=prop,

src/cfnlint/rules/resources/properties/NumberSize.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ def check(self, cfn, properties, specs, path):
7979
.get("ValueTypes")
8080
.get(value_type, {})
8181
)
82+
if value_specs == "CACHED":
83+
value_specs = (
84+
RESOURCE_SPECS.get("us-east-1")
85+
.get("ValueTypes")
86+
.get(value_type, {})
87+
)
8288
if (
8389
value_specs.get("NumberMax") is not None
8490
and value_specs.get("NumberMin") is not None

src/cfnlint/rules/resources/properties/StringSize.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,12 @@ def check(self, cfn, properties, specs, path):
6666
.get("ValueTypes")
6767
.get(value_type, {})
6868
)
69-
69+
if value_specs == "CACHED":
70+
value_specs = (
71+
RESOURCE_SPECS.get("us-east-1")
72+
.get("ValueTypes")
73+
.get(value_type, {})
74+
)
7075
if value_specs.get("StringMax") and value_specs.get(
7176
"StringMin"
7277
):

0 commit comments

Comments
 (0)