title | platform |
---|---|
About the google_compute_zones Resource |
gcp |
Use the google_compute_zones
InSpec audit resource to test properties of all, or a filtered group of, GCP compute zones for a project in a particular zone.
A google_compute_zones
resource block collects GCP zones by project then tests that group.
describe google_compute_zones(project: 'chef-inspec-gcp') do
it { should exist }
end
Use this InSpec resource to enumerate IDs then test in-depth using google_compute_zone
.
google_compute_zones(project: 'chef-inspec-gcp').zone_names.each do |zone_name|
describe google_compute_zone(project: 'chef-inspec-gcp', zone: zone_name) do
it { should exist }
its('kind') { should eq "compute#zone" }
its('status') { should eq 'UP' }
end
end
The following examples show how to use this InSpec audit resource.
describe google_compute_zones(project: 'chef-inspec-gcp') do
its('count') { should be <= 100}
end
describe google_compute_zones(project: 'chef-inspec-gcp') do
its('zone_ids.count') { should cmp 9 }
end
describe google_compute_zones(project: 'chef-inspec-gcp') do
its('zone_names') { should include "us-east1-b" }
end
describe google_compute_zones(project: 'chef-inspec-gcp') do
its('zone_statuses') { should_not include "DOWN" }
end
describe google_compute_zones(project: gcp_project_id).where(zone_name: /^us/).zone_names.each do |zone_name|
describe google_compute_zone(project: 'chef-inspec-gcp', zone: zone_name) do
it { should exist }
its('kind') { should eq "compute#zone" }
its('status') { should eq 'UP' }
end
end
This resource supports the following filter criteria: zone_id
; zone_name
and zone_status
. Any of these may be used with where
, as a block or as a method.
zone_ids
- an array of google_compute_zone identifier integerszone_names
- an array of google_compute_zone name stringszone_statuses
- an array of google_compute_zone statuses
Ensure the Compute Engine API is enabled for the project where the resource is located.