From 6e39e8cf67d0c6fe5769d56ab4a8d8152e491354 Mon Sep 17 00:00:00 2001 From: Kevin DeJong Date: Tue, 2 Jan 2024 09:53:23 -0800 Subject: [PATCH] Return dict str_node when doing transform (#2996) --- .../template/transforms/_language_extensions.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/cfnlint/template/transforms/_language_extensions.py b/src/cfnlint/template/transforms/_language_extensions.py index d4d9208d59..6d8b197305 100644 --- a/src/cfnlint/template/transforms/_language_extensions.py +++ b/src/cfnlint/template/transforms/_language_extensions.py @@ -14,6 +14,7 @@ import regex as re from cfnlint.conditions._utils import get_hash +from cfnlint.decode.node import str_node from cfnlint.helpers import FUNCTION_FOR_EACH from cfnlint.template.transforms._types import TransformResult @@ -197,10 +198,15 @@ def _replace_string_params( pattern = r"\${[a-zA-Z0-9\.:]+}" if not re.search(pattern, s): return (True, s) + + new_s = deepcopy(s) for k, v in params.items(): - s = re.sub(rf"\$\{{{k}\}}", v, s) + new_s = re.sub(rf"\$\{{{k}\}}", v, new_s) + + if isinstance(s, str_node): + new_s = str_node(new_s, s.start_mark, s.end_mark) - return (not (bool(re.search(pattern, s))), s) + return (not (bool(re.search(pattern, new_s))), new_s) class _ForEachValue: