Open walterdolce opened 5 years ago
FYI
I have already set the GOOGLE_APPLICATION_CREDENTIALS
environment variable pointing to my application_default_credentials.json
file.
InSpec version in use is 0.6.0
hi @walterdolce - as a first step, could you retry updating your top level inspec.yml
to a later InSpec version e.g.
inspec_version: '>= 2.2.10'
There's a minimal version specified in inspec-gcp however https://github.com/inspec/inspec/issues/3066 means that it might not be respected.
@skpaterson
It appears I was missing the zone
parameter in the test.
With the following, it kind of works:
describe google_compute_instance(project: gcp_project, zone: 'europe-west2-a', name: 'my-instance') do
Result:
× gcp-resources: Verify the state of the GCP resources (1 failed)
✔ Instance should exist
✔ Instance status should eq "RUNNING"
× Instance zone should eq "europe-west2-a"
expected: "europe-west2-a"
got: "https://www.googleapis.com/compute/v1/projects/{{gcp_project}}/zones/europe-west2-a"
(compared using ==)
This leads me to ask 2 questions:
1) Shouldn't Inspec GCP explicitly state that a certain resource parameter which is expected is missing? 2) It appears either the code or the docs are lying. The docs state that you can specify the zone name but as in the result above, the full GCP API URI is returned 🤔 Is this a bug in the code or in the docs?
Thanks!
Thanks for confirming that. For 1 above I'll add a TODO this side to improve checks on required parameters and fail more meaningfully!
For 2, so the docs read:
its('zone') { should match 'us-east1-b' }
Note match
not eq
. In some cases the resources will create helper functions to only return short names but here I was erring on the side of not curtailing the information returned via the API.
For 2, so the docs read [...] Note match not eq.
Of course! Silly me. Thanks for pointing that out @skpaterson :)
I guess we'll leave this issue open until the docs/code are updated (re: question 1 earlier)
Makes sense, thanks @walterdolce
I'm trying to verify whether a GCE instance exists with the following control:
But when I launch it I get the following:
What does that mean?