# Inspec GCP issue

**URL:** <https://discourse.chef.io/t/inspec-gcp-issue/13124>\
**Category:** Chef InSpec\
**Created:** [May 30, 2018, 12:16am UTC](https://discourse.chef.io/t/inspec-gcp-issue/13124 "2018-05-30T00:16:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Greg\_Pendler](https://avatars.discourse-cdn.com/v4/letter/g/e495f1/32.png) [@Greg\_Pendler](https://discourse.chef.io/u/Greg_Pendler)\
**Post date:** [May 30, 2018, 12:16am UTC](https://discourse.chef.io/t/inspec-gcp-issue/13124/1 "2018-05-30T00:16:44Z")

</div>

Trying to work with GCP and inspec. Hitting a wall. Not sure what i did wrong.

**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](mailto: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](https://github.com/inspec/inspec-gcp/archive/master.zip)

**The following 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 (require
```

---

<div class="post-metadata">

**Author:** ![spaterson](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/spaterson/32/2411_2.png) [@spaterson](https://discourse.chef.io/u/spaterson)\
**Post date:** [May 30, 2018, 8:34am UTC](https://discourse.chef.io/t/inspec-gcp-issue/13124/2 "2018-05-30T08:34:47Z")

</div>

Hi, sorry to hear things aren’t going smoothly! I’ve tried to reproduce locally with the following, similar files:

**$ cat inspec.yml**  
name: gcp-compliance-test  
title: InSpec Profile  
maintainer: The Authors  
copyright: The Authors  
copyright\_email: [you@example.com](mailto: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.tar.gz](https://github.com/inspec/inspec-gcp/archive/master.tar.gz)

**$ 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

When I run this via e.g.

**$ inspec exec . -t gcp://**

```
Profile: InSpec Profile (gcp-compliance-test)
Version: 0.1.0
Target: gcp://123455433[edited].1hur.apps.googleusercontent.com

Instance inspec-test
× Project 1233445[edited] is not found and cannot be used for API calls. If it is recently created, enable Compute Engine API by visiting https://console.developers.google.com/apis/api/compute.googleapis.com/overview?project=12344 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.

    Profile: Google Cloud Platform Resource Pack (inspec-gcp)
Version: 0.2.0
Target: gcp://238746238423489[edited].apps.googleusercontent.com

No tests executed.

    Test Summary: 0 successful, 1 failure, 0 skipped

```

Note that the **-t gcp://** is very important as it tells train to use the GCP transport. When I try with this missing, I see a similar traceback as above e.g.

```
$ inspec exec .
    libraries/google_compute_instance.rb:26:in `block in initialize': undefined method `gcp_compute_client' for #<Train::Transports::Local::Connection:0x00007f9a2a8f0d10> (NoMethodError)
  from libraries/gcp_backend.rb:28:in `catch_gcp_errors'
from libraries/google_compute_instance.rb:25:in `initialize'
  from /Users/spaterson/Documents/workspace/gcp/profile-tests/.direnv/ruby/gems/inspec-2.1.83/lib/inspec/plugins/resource.rb:68:in `initialize'
  from /Users/spaterson/Documents/workspace/gcp/profile-tests/.direnv/ruby/gems/inspec-2.1.83/lib/inspec/resource.rb:51:in `new'
from /Users/spaterson/Documents/workspace/gcp/profile-tests/.direnv/ruby/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 /Users/spaterson/Documents/workspace/gcp/profile-tests/.direnv/ruby/gems/inspec-2.1.83/lib/inspec/profile_context.rb:158:in `instance_eval'
from /Users/spaterson/Documents/workspace/gcp/profile-tests/.direnv/ruby/gems/inspec-2.1.83/lib/inspec/profile_context.rb:158:in `load_with_context'
  from /Users/spaterson/Documents/workspace/gcp/profile-tests/.direnv/ruby/gems/inspec-2.1.83/lib/inspec/profile_context.rb:142:in `load_control_file'
  from /Users/spaterson/Documents/workspace/gcp/profile-tests/.direnv/ruby/gems/inspec-2.1.83/lib/inspec/profile.rb:170:in `block in collect_tests'
from /Users/spaterson/Documents/workspace/gcp/profile-tests/.direnv/ruby/gems/inspec-2.1.83/lib/inspec/profile.rb:167:in `each'
  from /Users/spaterson/Documents/workspace/gcp/profile-tests/.direnv/ruby/gems/inspec-2.1.83/lib/inspec/profile.rb:167:in `collect_tests'
  from /Users/spaterson/Documents/workspace/gcp/profile-tests/.direnv/ruby/gems/inspec-2.1.83/lib/inspec/runner.rb:93:in `block in load'
from /Users/spaterson/Documents/workspace/gcp/profile-tests/.direnv/ruby/gems/inspec-2.1.83/lib/inspec/runner.rb:82:in `each'
  from /Users/spaterson/Documents/workspace/gcp/profile-tests/.direnv/ruby/gems/inspec-2.1.83/lib/inspec/runner.rb:82:in `load'
  from /Users/spaterson/Documents/workspace/gcp/profile-tests/.direnv/ruby/gems/inspec-2.1.83/lib/inspec/runner.rb:103:in `run'
from /Users/spaterson/Documents/workspace/gcp/profile-tests/.direnv/ruby/gems/inspec-2.1.83/lib/inspec/cli.rb:168:in `exec'
  from /Users/spaterson/Documents/workspace/gcp/profile-tests/.direnv/ruby/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
  from /Users/spaterson/Documents/workspace/gcp/profile-tests/.direnv/ruby/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
from /Users/spaterson/Documents/workspace/gcp/profile-tests/.direnv/ruby/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
  from /Users/spaterson/Documents/workspace/gcp/profile-tests/.direnv/ruby/gems/thor-0.20.0/lib/thor/base.rb:466:in `start'
  from /Users/spaterson/Documents/workspace/gcp/profile-tests/.direnv/ruby/gems/inspec-2.1.83/bin/inspec:12:in `<top (required)>'
from /Users/spaterson/Documents/workspace/gcp/profile-tests/.direnv/bin/inspec:29:in `load'
  from /Users/spaterson/Documents/workspace/gcp/profile-tests/.direnv/bin/inspec:29:in `<main>'

```

Does that help?

---

<div class="post-metadata">

**Author:** ![jquick](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/jquick/32/2192_2.png) [@jquick](https://discourse.chef.io/u/jquick)\
**Post date:** [May 30, 2018, 12:19pm UTC](https://discourse.chef.io/t/inspec-gcp-issue/13124/3 "2018-05-30T12:19:44Z")

</div>

Hello, It looks like you may of forgotten the gcp transport setting:

> #Train::Transports::Local::Connection:0x00007fcac1a532d0 (NoMethodError)

Make sure you add `-t gcp://` to your `inspec exec` call.

---

<div class="post-metadata">

**Author:** ![Greg\_Pendler](https://avatars.discourse-cdn.com/v4/letter/g/e495f1/32.png) [@Greg\_Pendler](https://discourse.chef.io/u/Greg_Pendler)\
**Post date:** [May 30, 2018, 6:10pm UTC](https://discourse.chef.io/t/inspec-gcp-issue/13124/4 "2018-05-30T18:10:09Z")

</div>

This works after specifying the transport. Thanks a lot!!

---

<div class="post-metadata">

**Author:** ![spaterson](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/spaterson/32/2411_2.png) [@spaterson](https://discourse.chef.io/u/spaterson)\
**Post date:** [May 31, 2018, 7:54am UTC](https://discourse.chef.io/t/inspec-gcp-issue/13124/5 "2018-05-31T07:54:50Z")

</div>

Good news, to make this clearer I’ll update the inspec-gcp readme to include a section on running with inspec.
