Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting Error: ERROR: Hook 'load_terraform_data' from /usr/local/lib/python3.7/site-packages/terraform_compliance/steps/terrain.py:5 raised: 'TypeError: 'NoneType' object is not iterable' #275

Closed
MartinLogan opened this issue May 21, 2020 · 3 comments
Assignees
Labels

Comments

@MartinLogan
Copy link
Contributor

MartinLogan commented May 21, 2020

Description :
It looks as though when encountering a module output that is just a list it is not seeing it as iterable.

If I move the declaration of the list to a local and then assign the local to the output value it succeeds

Tests added and proposed fix in a draft PR #276 - You can see the failure scenario there.

  1. terraform-compliance -p plan.out.json -f .
  2. Fails with both python and docker container
  3. Error output
mlogan at C02YV0U4LVCF in ~/Projects/mlogan/terraform-compliance/tests/functional/test_module_output_list on master [?]
$ terraform-compliance -p plan.out.json -f .
terraform-compliance v1.2.1 initiated

🚩 Features	: /target
🚩 Plan File	: /target/plan.out.json

🚩 Running tests. 🎉

Feature: The scenarios defined below  # /target/security_group.feature
    require an MR review if any
    of the resources below exist
    in a plan
1 features (0 passed)
4 scenarios (0 passed)
8 steps (0 passed)
Run 1590092214 finished within a moment
❗ ERROR: Hook 'load_terraform_data' from /usr/local/lib/python3.7/site-packages/terraform_compliance/steps/terrain.py:5 raised: 'TypeError: 'NoneType' object is not iterable'

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 42, in __init__
    self.parse()
  File "/usr/local/lib/python3.7/site-packages/terraform_compliance/extensions/terraform.py", line 344, in parse
    self._mount_references()
  File "/usr/local/lib/python3.7/site-packages/terraform_compliance/extensions/terraform.py", line 289, in _mount_references
    ref_list[key] = self._find_resource_from_name(ref)
  File "/usr/local/lib/python3.7/site-packages/terraform_compliance/extensions/terraform.py", line 259, in _find_resource_from_name
    resources = ['{}.{}.{}'.format(resource_type, module_name, res) for res in resources]
TypeError: 'NoneType' object is not iterable
  1. Simple feature failure test - can be anything
Feature: The scenarios defined below
	 require an MR review if any
	 of the resources below exist
	 in a plan

Scenario Outline: changes to specific resources
    Given I have <resource> defined
    Then the scenario should fail

    Examples:
      | resource                       |
      | aws_elasticache_security_group |
      | aws_default_security_group     |
      | aws_security_group             |
      | aws_security_group_rule        |

Expected behavior :

Tested versions :

  • terraform-compliance version 1.2.1
  • terraform version 0.12.13
  • <python runtime version, 3.7.7 (BUt fails from docker as well)

Additional context
Add any other context about the problem here.

@eerkunt
Copy link
Member

eerkunt commented May 25, 2020

Releasing 1.2.3 with changes including your PR.

@eerkunt
Copy link
Member

eerkunt commented Jun 7, 2020

Assuming this is fixed with #276 by yourself, closing the issue.

Please let me know if the problem still persists.

Thanks 🎉

@eerkunt eerkunt closed this as completed Jun 7, 2020
@ghost
Copy link

ghost commented Jun 7, 2020

This issue's conversation is now locked. If you want to continue this discussion please open a new issue.

@ghost ghost locked and limited conversation to collaborators Jun 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants