diff --git a/CHANGELOG.md b/CHANGELOG.md index 23659344..71832cf4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,11 @@ # CHANGELOG +## 1.1.9 (2020-02-25) +* Fixed a problem where a property within the terraform plan fails to get parsed if it is list of lists. ([#221](https://github.com/eerkunt/terraform-compliance/issues/221)) + ## 1.1.8 (2020-02-23) * Fixed a problem where tags are not recognised on Auto-Scaling Groups due to different key/pair structure within the terraform. ([#208](https://github.com/eerkunt/terraform-compliance/issues/208)) - ## 1.1.7 (2020-02-06) * Fixed a case where resource referencing fails when the output is coming from a module and does not registered in terraform plan. diff --git a/terraform_compliance/steps/steps.py b/terraform_compliance/steps/steps.py index f22ca036..3cf10940 100644 --- a/terraform_compliance/steps/steps.py +++ b/terraform_compliance/steps/steps.py @@ -267,9 +267,11 @@ def its_key_is_not_value(_step_obj, key, value): @when(u'it has {something:ANY}') @when(u'it contains {something:ANY}') @then(u'it must contain {something:ANY}') -def it_condition_contain_something(_step_obj, something): +def it_condition_contain_something(_step_obj, something, inherited_values=Null): prop_list = [] + _step_obj.context.stash = inherited_values if inherited_values is not Null else _step_obj.context.stash + if _step_obj.context.type in ('resource', 'data'): for resource in _step_obj.context.stash: if not isinstance(resource, dict) \ @@ -315,6 +317,8 @@ def it_condition_contain_something(_step_obj, something): found_key = found_key[0] found_value = value.get('value') break + elif isinstance(value, list): + found_key, found_value = it_condition_contain_something(_step_obj, something, value) if found_key is not Null and len(found_key): found_key = found_key[0] if len(found_key) == 1 else found_key @@ -338,7 +342,7 @@ def it_condition_contain_something(_step_obj, something): if prop_list: _step_obj.context.stash = prop_list _step_obj.context.property_name = something - return True + return something, prop_list if _step_obj.state != Step.State.FAILED: skip_step(_step_obj,