mattray / inspec-iggy

InSpec CLI plugin for generating compliance controls from Terraform and CloudFormation
Apache License 2.0
106 stars 18 forks source link

undefined method `each' for nil:NilClass (NoMethodError) #31

Closed mmclane closed 4 years ago

mmclane commented 4 years ago

Describe the bug I thought I would give inspec-iggy a look. I am running on Ubuntu 18.04.1 LTS. I downloaded and installed inspec 4.16.0. I then ran inspec plugin install inspec-iggy and it installed version 0.6.0. I downloaded my terraform.tfstate file from S3 and ran

inspec terraform generate --tfstate terraform.tfstate --name myprofile

I get the following:

Traceback (most recent call last):
        15: from /usr/bin/inspec:186:in `<main>'
        14: from /usr/bin/inspec:186:in `load'
        13: from /opt/inspec/embedded/lib/ruby/gems/2.6.0/gems/inspec-bin-4.16.0/bin/inspec:11:in `<top (required)>'
        12: from /opt/inspec/embedded/lib/ruby/gems/2.6.0/gems/inspec-4.16.0/lib/inspec/base_cli.rb:33:in `start'
        11: from /opt/inspec/embedded/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/base.rb:466:in `start'
        10: from /opt/inspec/embedded/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
         9: from /opt/inspec/embedded/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
         8: from /opt/inspec/embedded/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
         7: from /opt/inspec/embedded/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor.rb:238:in `block in subcommand'
         6: from /opt/inspec/embedded/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/invocation.rb:115:in `invoke'
         5: from /opt/inspec/embedded/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
         4: from /opt/inspec/embedded/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
         3: from /opt/inspec/embedded/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
         2: from /home/mmclane/.inspec/gems/2.6.0/gems/inspec-iggy-0.6.0/lib/inspec-iggy/terraform/cli_command.rb:90:in `generate'
         1: from /home/mmclane/.inspec/gems/2.6.0/gems/inspec-iggy-0.6.0/lib/inspec-iggy/terraform/generate.rb:20:in `parse_generate'
/home/mmclane/.inspec/gems/2.6.0/gems/inspec-iggy-0.6.0/lib/inspec-iggy/terraform/generate.rb:33:in `parse_resources': undefined method `each' for nil:NilClass (NoMethodError)

Environment

To Reproduce Please provide the commands used to reproduce the behavior. If controls are being rendered that do not work, please post the generated controls.rb. If possible please share sanitized source files. See above

Expected behavior A clear and concise description of what you expected to happen. I expect the command to run successfully and create an inspec profile.

Additional context Add any other context about the problem here.

mattray commented 4 years ago

I haven't had a chance to update Iggy to work with Terraform 0.12 yet, that's probably the source of the issue. I'm hoping to start working on it this upcoming week.

mmclane commented 4 years ago

ah.. ok. Let me know if I can help test or validate anything.

mmclane commented 4 years ago

Any update on this?

mattray commented 4 years ago

Sorry, I've been swamped with other work. I'll try to get to this soon.

dkooll commented 4 years ago

i can confirm i have the same issue using terraform version 0.12.9

pcazenav commented 4 years ago

Hi I ran into the same issued using Terraform 0.12.6 Is there any update about this ? Thanks

gavinmoorcroft commented 4 years ago

Hi,

I am also getting this issue but we are on terraform 11.14.

What is the latest version of terraform that iggy is supposed to work with??

mattray commented 4 years ago

The new releases of Iggy have been tested on Terraform 0.12, I doubt 0.11 still works. If you're continuing to have issues after upgrading please let me know. Most of my testing has been with AWS and GCP, so if you're using Azure please let me know because I know it needs more attention. I'm going to go ahead and close this, please open a new issue if it persists with the latest Iggy/Terraform combination.

anoopsharma81 commented 4 years ago

I am getting same error terraform version 12.16 15: from /usr/local/bin/inspec:356:in <main>' 14: from /usr/local/bin/inspec:356:inload' 13: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/inspec-bin-4.16.0/bin/inspec:11:in <top (required)>' 12: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/inspec-4.16.0/lib/inspec/base_cli.rb:33:instart' 11: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/base.rb:466:in start' 10: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor.rb:387:indispatch' 9: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in invoke_command' 8: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/command.rb:27:inrun' 7: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor.rb:238:in block in subcommand' 6: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/invocation.rb:115:ininvoke' 5: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor.rb:387:in dispatch' 4: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:ininvoke_command' 3: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/command.rb:27:in run' 2: from /Users/anup.sharma/.inspec/gems/2.6.0/gems/inspec-iggy-0.6.0/lib/inspec-iggy/terraform/cli_command.rb:90:ingenerate' 1: from /Users/anup.sharma/.inspec/gems/2.6.0/gems/inspec-iggy-0.6.0/lib/inspec-iggy/terraform/generate.rb:20:in parse_generate' /Users/anup.sharma/.inspec/gems/2.6.0/gems/inspec-iggy-0.6.0/lib/inspec-iggy/terraform/generate.rb:33:inparse_resources': undefined method `each' for nil:NilClass (NoMethodError) C02YD2B1JG5L:inspec anup.sharma$ terraform version Terraform v0.12.16 inspec-iggy (0.8.0) Inspec 4.16.0