Skip to content

Commit

Permalink
v1 - Enumerate FindInMap when can't be resolved (#3247)
Browse files Browse the repository at this point in the history
* Enumerate FindInMap when can't be resolved
* Update pre-commit
  • Loading branch information
kddejong authored May 14, 2024
1 parent 66fc7fa commit d4eda4d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: check-ast
- id: check-json
Expand All @@ -16,26 +16,26 @@ repos:
args: [--fix, auto]
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 24.2.0
rev: 24.4.2
hooks:
- id: black
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.2.2"
rev: "v0.4.4"
hooks:
- id: ruff
- repo: https://github.com/PyCQA/bandit
rev: "1.7.7"
rev: "1.7.8"
hooks:
- id: bandit
additional_dependencies:
- "bandit[toml]"
args: ["-c", "pyproject.toml"]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.8.0"
rev: "v1.10.0"
hooks:
- id: mypy
additional_dependencies:
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,20 +159,16 @@ 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 d4eda4d

Please sign in to comment.