Skip to content

Instantly share code, notes, and snippets.

@gpendler
Last active May 30, 2018 00:04
Show Gist options
  • Save gpendler/0a7a436562928d17fd1efc9a86a48677 to your computer and use it in GitHub Desktop.
Save gpendler/0a7a436562928d17fd1efc9a86a48677 to your computer and use it in GitHub Desktop.
GCP Inspec not working
gcp-compliance ➤ cat controls/example.rb
describe google_compute_instance(project: 'my-proj', zone: 'us-east1-b', name: 'inspec-test') do
it { should exist }
its('name') { should eq 'inspec-test' }
its('machine_type') { should eq 'f1-micro' }
its('cpu_platform') { should match 'Intel' }
its('status') { should eq 'RUNNING' }
end
gcp-compliance ➤ cat inspec.yml
name: gcp-compliance-new
title: InSpec Profile
maintainer: The Authors
copyright: The Authors
copyright_email: you@example.com
license: Apache-2.0
summary: An InSpec Compliance Profile
version: 0.1.0
depends:
- name: google
url: https://github.com/inspec/inspec-gcp/archive/master.zip
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
results in
libraries/google_compute_instance.rb:26:in `block in initialize': undefined method `gcp_compute_client' for #<Train::Transports::Local::Connection:0x00007fcac1a532d0> (NoMethodError)
from libraries/gcp_backend.rb:28:in `catch_gcp_errors'
from libraries/google_compute_instance.rb:25:in `initialize'
from /opt/inspec/embedded/lib/ruby/gems/2.4.0/gems/inspec-2.1.83/lib/inspec/plugins/resource.rb:68:in `initialize'
from /opt/inspec/embedded/lib/ruby/gems/2.4.0/gems/inspec-2.1.83/lib/inspec/resource.rb:51:in `new'
from /opt/inspec/embedded/lib/ruby/gems/2.4.0/gems/inspec-2.1.83/lib/inspec/resource.rb:51:in `block (3 levels) in create_dsl'
from ./controls/example.rb:1:in `load_with_context'
from /opt/inspec/embedded/lib/ruby/gems/2.4.0/gems/inspec-2.1.83/lib/inspec/profile_context.rb:158:in `instance_eval'
from /opt/inspec/embedded/lib/ruby/gems/2.4.0/gems/inspec-2.1.83/lib/inspec/profile_context.rb:158:in `load_with_context'
from /opt/inspec/embedded/lib/ruby/gems/2.4.0/gems/inspec-2.1.83/lib/inspec/profile_context.rb:142:in `load_control_file'
from /opt/inspec/embedded/lib/ruby/gems/2.4.0/gems/inspec-2.1.83/lib/inspec/profile.rb:170:in `block in collect_tests'
from /opt/inspec/embedded/lib/ruby/gems/2.4.0/gems/inspec-2.1.83/lib/inspec/profile.rb:167:in `each'
from /opt/inspec/embedded/lib/ruby/gems/2.4.0/gems/inspec-2.1.83/lib/inspec/profile.rb:167:in `collect_tests'
from /opt/inspec/embedded/lib/ruby/gems/2.4.0/gems/inspec-2.1.83/lib/inspec/runner.rb:93:in `block in load'
from /opt/inspec/embedded/lib/ruby/gems/2.4.0/gems/inspec-2.1.83/lib/inspec/runner.rb:82:in `each'
from /opt/inspec/embedded/lib/ruby/gems/2.4.0/gems/inspec-2.1.83/lib/inspec/runner.rb:82:in `load'
from /opt/inspec/embedded/lib/ruby/gems/2.4.0/gems/inspec-2.1.83/lib/inspec/runner.rb:103:in `run'
from /opt/inspec/embedded/lib/ruby/gems/2.4.0/gems/inspec-2.1.83/lib/inspec/cli.rb:168:in `exec'
from /opt/inspec/embedded/lib/ruby/gems/2.4.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
from /opt/inspec/embedded/lib/ruby/gems/2.4.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
from /opt/inspec/embedded/lib/ruby/gems/2.4.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
from /opt/inspec/embedded/lib/ruby/gems/2.4.0/gems/thor-0.20.0/lib/thor/base.rb:466:in `start'
from /opt/inspec/embedded/lib/ruby/gems/2.4.0/gems/inspec-2.1.83/bin/inspec:12:in `<top (required)>'
from /usr/local/bin/inspec:137:in `load'
from /usr/local/bin/inspec:137:in `<main>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment