From cb9864bf526101b1112dafd8abfc27c5000b7c85 Mon Sep 17 00:00:00 2001 From: lirshindalman Date: Sun, 1 Oct 2023 18:00:17 +0300 Subject: [PATCH] check if the dynamic name is one of the resources block --- checkov/terraform/parser_functions.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/checkov/terraform/parser_functions.py b/checkov/terraform/parser_functions.py index 1778cc9fcd9..8324ffbb49c 100644 --- a/checkov/terraform/parser_functions.py +++ b/checkov/terraform/parser_functions.py @@ -199,7 +199,13 @@ def process_dynamic_values(conf: Dict[str, List[Any]]) -> bool: for element_name, element_value in dynamic_element.items(): if "content" in element_value: - conf[element_name] = element_value["content"] + if element_name in conf: + if isinstance(conf[element_name], list): + conf[element_name].append(element_value["content"]) + else: + conf[element_name] = [conf[element_name], element_value["content"]] + else: + conf[element_name] = element_value["content"] else: # this should be the result of a successful dynamic block rendering # in some cases a whole dict is added, which doesn't have a list around it