# Buggy code
def _mount_resources(self, source, target, ref_type):
    """
    Mounts values of the source resource to the target resource's values with ref_type key

    :param source: source resource
    :param target:  target resource
    :param ref_type: reference type (e.g. ingress )
    :return: none
    """
    for source_resource in source:
        for target_resource in target:
            if ref_type not in self.resources[target_resource]["values"]:
                self.resources[target_resource]["values"][ref_type] = list()
                self.resources[target_resource]["values"][ref_type].append(
                    self.resources[source_resource]["values"]
                )
            else:
                self.resources[target_resource]["values"][ref_type].append(
                    self.resources[source_resource]["values"]
                )


# Traceback (KeyError)
$ terraform-compliance -p /target/tc-test2/tf-template/jenkins.plan.out.json -f /target/tc-test2/features
terraform-compliance v1.0.13 initiated

* Features  : /target/tc-test2/features
* Plan File : /target/tc-test2/tf-template/jenkins.plan.out.json

. Running tests.
Feature: Resources should be properly tagged  # /target/tc-test2/features/tags.feature
In order to keep track of resource ownership
As engineers
We'll enforce tagging on all resources
2 features (0 passed)
30 scenarios (0 passed)
109 steps (0 passed)
Run 1562934682 finished within a moment
Error: Hook 'load_terraform_data' from /usr/local/lib/python3.7/site-packages/terraform_compliance/steps/terrain.py:5 raised: 'KeyError: 'values''

Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/radish/hookregistry.py", line 132, in call
func(model, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/terraform_compliance/steps/terrain.py", line 7, in load_terraform_data
world.config.terraform = TerraformParser(world.config.user_data['plan_file'])
File "/usr/local/lib/python3.7/site-packages/terraform_compliance/extensions/terraform.py", line 34, in __init__
self.parse()
File "/usr/local/lib/python3.7/site-packages/terraform_compliance/extensions/terraform.py", line 225, in parse
self._mount_references()
File "/usr/local/lib/python3.7/site-packages/terraform_compliance/extensions/terraform.py", line 200, in _mount_references
self._mount_resources(source_resources, flatten_list(ref_list), ref_type)
File "/usr/local/lib/python3.7/site-packages/terraform_compliance/extensions/terraform.py", line 153, in _mount_resources
self.resources[target_resource]['values'][ref_type].append(self.resources[source_resource]['values'])
KeyError: 'values'

# Fixed code
def _mount_resources(self, source, target, ref_type):
    """
    Mounts values of the source resource to the target resource's values with ref_type key

    :param source: source resource
    :param target:  target resource
    :param ref_type: reference type (e.g. ingress )
    :return: none
    """
    for source_resource in source:
        if "values" not in self.resources[source_resource]:
            continue

        for target_resource in target:
            if "values" not in self.resources[target_resource]:
                continue

            if ref_type not in self.resources[target_resource]["values"]:
                self.resources[target_resource]["values"][ref_type] = list()
                self.resources[target_resource]["values"][ref_type].append(
                    self.resources[source_resource]["values"]
                )
            else:
                self.resources[target_resource]["values"][ref_type].append(
                    self.resources[source_resource]["values"]
                )