Repository: bridgecrewio/checkov

Issue:
Key error in checkov 
**Describe the issue**
Explain what you expected to happen when checkov crashed.
Checkov crushed when scanning a cloned git project: 
https://github.com/clowdhaus/terraform-aws-batch
**Exception Trace**
 checkov -d .
2022-01-27 09:26:35,772 [MainThread  ] [WARNI]  Failed to download module terraform-aws-modules/vpc/aws:3.0 (for external modules, the --download-external-modules flag is required)
2022-01-27 09:26:35,773 [MainThread  ] [WARNI]  Failed to download module terraform-aws-modules/vpc/aws//modules/vpc-endpoints:3.0 (for external modules, the --download-external-modules flag is required)
2022-01-27 09:26:35,774 [MainThread  ] [WARNI]  Failed to download module terraform-aws-modules/security-group/aws:4.0 (for external modules, the --download-external-modules flag is required)
Process ForkProcess-1:
Traceback (most recent call last):
  File "/usr/local/Cellar/python@3.9/3.9.8/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/usr/local/Cellar/python@3.9/3.9.8/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.9/site-packages/checkov/common/parallelizer/parallel_runner.py", line 29, in func_wrapper
    result = original_func(item)
  File "/usr/local/lib/python3.9/site-packages/checkov/common/runners/runner_registry.py", line 63, in <lambda>
    lambda runner: runner.run(root_folder, external_checks_dir=external_checks_dir, files=files,
  File "/usr/local/lib/python3.9/site-packages/checkov/terraform/runner.py", line 93, in run
    local_graph, tf_definitions = self.graph_manager.build_graph_from_source_directory(
  File "/usr/local/lib/python3.9/site-packages/checkov/terraform/graph_manager.py", line 39, in build_graph_from_source_directory
    local_graph.build_graph(render_variables=render_variables)
  File "/usr/local/lib/python3.9/site-packages/checkov/terraform/graph_builder/local_graph.py", line 50, in build_graph
    self._build_edges()
  File "/usr/local/lib/python3.9/site-packages/checkov/terraform/graph_builder/local_graph.py", line 163, in _build_edges
    self.get_module_vertices_mapping()
  File "/usr/local/lib/python3.9/site-packages/checkov/terraform/graph_builder/local_graph.py", line 150, in get_module_vertices_mapping
    module_dependency_num = self.module.module_address_map[(module_vertex.path, module_vertex.name)]
KeyError: ('/Users/barak/Documents/dev/bridgecrew/terraform-aws-batch/examples/ec2/main.tf', 'vpc')

**Desktop (please complete the following information):**
 - OS: [e.g. iOS] mac
 - Checkov Version 2.0.766

**Additional context**
Add any other context about the problem here (e.g. code snippets).



Discussion:
I am also getting this error. 

Resolving patch:
diff --git a/checkov/terraform/graph_builder/local_graph.py b/checkov/terraform/graph_builder/local_graph.py
--- a/checkov/terraform/graph_builder/local_graph.py
+++ b/checkov/terraform/graph_builder/local_graph.py
@@ -147,8 +147,9 @@ def get_module_vertices_mapping(self) -> None:
                             dest_module_version=module_version
                         )
                         if dest_module_path == dir_name:
-                            module_dependency_num = self.module.module_address_map[(module_vertex.path, module_vertex.name)]
-                            block_dirs_to_modules[(dir_name, path_to_module_str)].setdefault(module_dependency_num, set()).add(module_index)
+                            module_dependency_num = self.module.module_address_map.get((module_vertex.path, module_vertex.name))
+                            if module_dependency_num:
+                                block_dirs_to_modules[(dir_name, path_to_module_str)].setdefault(module_dependency_num, set()).add(module_index)
 
         for vertex in self.vertices:
             # match the right module vertex according to the vertex path directory


Test patch: