inspec-aws errors on running an exec

425 views Asked by At

Any idea what im doing wrong i have chefworkstation installed:

$ chef -v
Chef Workstation version: 21.4.365
Chef Infra Client version: 16.12.3
Chef InSpec version: 4.29.3
Chef CLI version: 4.0.0
Chef Habitat version: 1.6.288
Test Kitchen version: 2.11.2
Cookstyle version: 7.10.0

aws cli is installed and i have set up a default credentials that are working (confirmed via deploying some tf code)

Created a folder and ran

inspec init profile --platform aws tftest

Install the aws-sdk for 2.7.3 (Using rbenv) and bundle to install the sdk

Gemfile

source 'https://rubygems.org/' do
    gem 'aws-sdk', '~> 3'
end

I then run:

inspec exec tftest -t aws://

and get the below error:

$ inspec exec tftest -t aws://
Traceback (most recent call last):
        30: from /usr/bin/inspec:354:in `<main>'
        29: from /usr/bin/inspec:354:in `load'
        28: from /opt/chef-workstation/embedded/lib/ruby/gems/2.7.0/gems/inspec-bin-4.29.3/bin/inspec:11:in `<top (required)>'
        27: from /opt/chef-workstation/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-4.29.3/lib/inspec/base_cli.rb:35:in `start'
        26: from /opt/chef-workstation/embedded/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor/base.rb:485:in `start'
        25: from /opt/chef-workstation/embedded/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor.rb:392:in `dispatch'
        24: from /opt/chef-workstation/embedded/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor/invocation.rb:127:in `invoke_command'
        23: from /opt/chef-workstation/embedded/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor/command.rb:27:in `run'
        22: from /opt/chef-workstation/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-4.29.3/lib/inspec/cli.rb:281:in `exec'
        21: from /opt/chef-workstation/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-4.29.3/lib/inspec/runner.rb:135:in `run'
        20: from /opt/chef-workstation/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-4.29.3/lib/inspec/runner.rb:101:in `load'
        19: from /opt/chef-workstation/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-4.29.3/lib/inspec/runner.rb:101:in `each'
        18: from /opt/chef-workstation/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-4.29.3/lib/inspec/runner.rb:107:in `block in load'
        17: from /opt/chef-workstation/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-4.29.3/lib/inspec/profile.rb:259:in `load_libraries'
        16: from /opt/chef-workstation/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-4.29.3/lib/inspec/profile.rb:259:in `each_with_index'
        15: from /opt/chef-workstation/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-4.29.3/lib/inspec/profile.rb:259:in `each'
        14: from /opt/chef-workstation/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-4.29.3/lib/inspec/profile.rb:278:in `block in load_libraries'
        13: from /opt/chef-workstation/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-4.29.3/lib/inspec/profile.rb:285:in `load_libraries'
        12: from /opt/chef-workstation/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-4.29.3/lib/inspec/profile_context.rb:143:in `load_libraries'
        11: from /opt/chef-workstation/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-4.29.3/lib/inspec/profile_context.rb:143:in `each'
        10: from /opt/chef-workstation/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-4.29.3/lib/inspec/profile_context.rb:144:in `block in load_libraries'
         9: from /opt/chef-workstation/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-4.29.3/lib/inspec/profile_context.rb:159:in `load_library_file'
         8: from /opt/chef-workstation/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-4.29.3/lib/inspec/profile_context.rb:170:in `load_with_context'
         7: from /opt/chef-workstation/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-4.29.3/lib/inspec/profile_context.rb:170:in `instance_eval'
         6: from libraries/aws_alb.rb:3:in `load_with_context'
         5: from /opt/chef-workstation/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-4.29.3/lib/inspec/dsl_shared.rb:47:in `require'
         4: from /opt/chef-workstation/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-4.29.3/lib/inspec/dsl_shared.rb:47:in `eval'
         3: from libraries/aws_backend.rb:13:in `create'
         2: from /opt/chef-workstation/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-4.29.3/lib/inspec/dsl_shared.rb:33:in `require'
         1: from /opt/chef-workstation/embedded/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:83:in `require'
/opt/chef-workstation/embedded/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:83:in `require': cannot load such file -- aws-sdk-ecrpublic (LoadError)

I tried updating my Gemfile to include gem 'aws-sdk-ecrpublic' but i still get the same error

folder layout is:

.
├── Gemfile
├── Gemfile.lock
├── README.md
├── .ruby-version
└── tftest
    ├── controls
    │   └── example.rb
    ├── inspec.lock
    ├── inspec.yml
    └── README.md

Any idea whats wrong?

1

There are 1 answers

0
vasu On

its a very late answer to this question but inspec-aws has dependency on train-aws which need to be installed. https://github.com/inspec/train-aws