From d4eda4dfe30bbe5b1571597b0e653a532077f416 Mon Sep 17 00:00:00 2001 From: Kevin DeJong Date: Tue, 14 May 2024 09:36:52 -0700 Subject: [PATCH] v1 - Enumerate FindInMap when can't be resolved (#3247) * Enumerate FindInMap when can't be resolved * Update pre-commit --- .pre-commit-config.yaml | 10 +++++----- .../template/transforms/_language_extensions.py | 10 +++------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3223e8a417..42dc386a5c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 @@ -16,7 +16,7 @@ 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 @@ -24,18 +24,18 @@ repos: 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: diff --git a/src/cfnlint/template/transforms/_language_extensions.py b/src/cfnlint/template/transforms/_language_extensions.py index 5698917fe9..82cda1e57d 100644 --- a/src/cfnlint/template/transforms/_language_extensions.py +++ b/src/cfnlint/template/transforms/_language_extensions.py @@ -159,10 +159,6 @@ 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 @@ -170,9 +166,9 @@ def _walk(self, item: Any, params: MutableMapping[str, Any], cfn: Any): # 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: