Skip to content

Commit

Permalink
Enumerate FindInMap when can't be resolved (#3246)
Browse files Browse the repository at this point in the history
* Enumerate FindInMap when can't be resolved
* Fix new pylint issues
  • Loading branch information
kddejong authored May 14, 2024
1 parent 592ce0b commit 118686c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
3 changes: 1 addition & 2 deletions src/cfnlint/rules/resources/events/RuleScheduleExpression.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,9 @@ def check_rate(self, value, path):
RuleMatch(path, f"Rate Value {items[0]!r} should be greater than 0.")
]

valid_periods = ["minutes", "hours", "days"]
if float(items[0]) <= 1:
valid_periods = ["minute", "hour", "day"]
elif float(items[0]) > 1:
valid_periods = ["minutes", "hours", "days"]
# Check the Unit
if items[1] not in valid_periods:
return [
Expand Down
2 changes: 2 additions & 0 deletions src/cfnlint/rules/resources/properties/ValueRefGetAtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ def check_value_getatt(self, value, path, **kwargs):
property_type = kwargs.get("property_type")
property_name = kwargs.get("property_name")
# You can sometimes get a list or a string with . in it
resource_name = ""
resource_attribute = []
if isinstance(value, list):
resource_name = value[0]
if len(value[1:]) == 1:
Expand Down
10 changes: 3 additions & 7 deletions src/cfnlint/template/transforms/_language_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,19 +159,15 @@ def _walk(self, item: Any, params: MutableMapping[str, Any], cfn: Any):
try:
mapping = _ForEachValueFnFindInMap(get_hash(v), v)
map_value = mapping.value(cfn, params, True, False)
# if we get None this means its all strings but couldn't be resolved
# we will pass this forward
if map_value is None:
continue
# if we can resolve it we will return it
if isinstance(map_value, tuple([list]) + _SCALAR_TYPES):
return map_value
except Exception as e: # pylint: disable=broad-exception-caught
# We couldn't resolve the FindInMap so we are going to leave it as it is
LOGGER.debug("Transform and Fn::FindInMap error: %s", {str(e)})
for i, el in enumerate(v):
v[i] = self._walk(el, params, cfn)
obj[k] = v
for i, el in enumerate(v):
v[i] = self._walk(el, params, cfn)
obj[k] = v
elif k == "Ref":
if isinstance(v, str):
if v in params:
Expand Down

0 comments on commit 118686c

Please sign in to comment.