Skip to content

Commit 81dac9a

Browse files
authored
Read cached from us-east-1 in W2030 and E3008 (#2635)
* Read cached from us-east-1 in W2030 and E3008
1 parent b197326 commit 81dac9a

File tree

4 files changed

+28
-12
lines changed

4 files changed

+28
-12
lines changed

.coveragerc

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
[run]
22
branch = True
3-
include =
4-
*src/cfnlint/*
3+
include = src/cfnlint/*

src/cfnlint/rules/parameters/AllowedValue.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ def initialize(self, cfn):
2828
):
2929
self.resource_sub_property_types.append(property_type_spec)
3030

31+
def _get_value_specs(self, value_type, region):
32+
value_specs = RESOURCE_SPECS.get(region).get("ValueTypes").get(value_type, {})
33+
if value_specs == "CACHED":
34+
value_specs = (
35+
RESOURCE_SPECS.get("us-east-1").get("ValueTypes").get(value_type, {})
36+
)
37+
return value_specs
38+
3139
def check_value_ref(self, value, path, **kwargs):
3240
"""Check Ref"""
3341
matches = []
@@ -111,15 +119,14 @@ def check(self, cfn, properties, value_specs, property_specs, path):
111119
property_type = (
112120
property_specs.get("Properties").get(prop).get("Type")
113121
)
122+
type_specs = self._get_value_specs(value_type, cfn.regions[0])
114123
matches.extend(
115124
cfn.check_value(
116125
p_value,
117126
prop,
118127
p_path,
119128
check_ref=self.check_value_ref,
120-
value_specs=RESOURCE_SPECS.get(cfn.regions[0])
121-
.get("ValueTypes")
122-
.get(value_type, {}),
129+
value_specs=type_specs,
123130
cfn=cfn,
124131
property_type=property_type,
125132
property_name=prop,

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

+16-6
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,14 @@ def check_value_getatt(self, value, path, **kwargs):
234234

235235
return matches
236236

237+
def _get_value_specs(self, value_type, region):
238+
value_specs = RESOURCE_SPECS.get(region).get("ValueTypes").get(value_type, {})
239+
if value_specs == "CACHED":
240+
value_specs = (
241+
RESOURCE_SPECS.get("us-east-1").get("ValueTypes").get(value_type, {})
242+
)
243+
return value_specs
244+
237245
def check(self, cfn, properties, value_specs, property_specs, path):
238246
"""Check itself"""
239247
matches = []
@@ -247,19 +255,21 @@ def check(self, cfn, properties, value_specs, property_specs, path):
247255
property_type = (
248256
property_specs.get("Properties").get(prop).get("Type")
249257
)
258+
value_type_specs = self._get_value_specs(
259+
value_type, cfn.regions[0]
260+
)
261+
list_value_specs = self._get_value_specs(
262+
list_value_type, cfn.regions[0]
263+
)
250264
matches.extend(
251265
cfn.check_value(
252266
p_value,
253267
prop,
254268
p_path,
255269
check_ref=self.check_value_ref,
256270
check_get_att=self.check_value_getatt,
257-
value_specs=RESOURCE_SPECS.get(cfn.regions[0])
258-
.get("ValueTypes")
259-
.get(value_type, {}),
260-
list_value_specs=RESOURCE_SPECS.get(cfn.regions[0])
261-
.get("ValueTypes")
262-
.get(list_value_type, {}),
271+
value_specs=value_type_specs,
272+
list_value_specs=list_value_specs,
263273
cfn=cfn,
264274
property_type=property_type,
265275
property_name=prop,

tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ commands =
88
coverage xml
99
skip_install = True
1010
deps =
11-
coverage<7.0.0
11+
coverage>=7.2.1
1212
pydot
1313
setenv =
1414
LANG=en_US.UTF-8

0 commit comments

Comments
 (0)