Syntax

A google_compute_zones is used to test a Google Zone resource

Beta Resource

This resource has beta fields available. To retrieve these fields, include beta: true in the constructor for the resource

Examples

google_compute_zones(project: 'chef-gcp-inspec').zone_names.each do |zone_name|
  describe google_compute_zone(project: 'chef-gcp-inspec', name: zone_name) do
    it { should exist }
    it { should be_up }
  end
end

Test that there are no more than a specified number of zones available for the project

describe google_compute_zones(project: 'chef-inspec-gcp') do
  its('count') { should be <= 100}
end

Test the exact number of zones in the project

describe google_compute_zones(project: 'chef-inspec-gcp') do
  its('zone_ids.count') { should cmp 9 }
end

Test that an expected zone is available for the project

describe google_compute_zones(project: 'chef-inspec-gcp') do
  its('zone_names') { should include "us-east1-b" }
end

Test whether any zones are in status “DOWN”

describe google_compute_zones(project: 'chef-inspec-gcp') do
  its('zone_statuses') { should_not include "DOWN" }
end

Test that a subset of all zones matching “us*” are “UP”

google_compute_zones(project: 'chef-inspec-gcp').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('status') { should eq 'UP' }
  end
end

Properties

Properties that can be accessed from the google_compute_zones resource:

See googlecomputezone.md for more detailed information * creation_timestamps: an array of google_compute_zone creationtimestamp * deprecateds: an array of `googlecomputezonedeprecated *descriptions: an array ofgooglecomputezonedescription *zoneids: an array ofgooglecomputezoneid *zonenames: an array ofgooglecomputezonename *regions: an array ofgooglecomputezoneregion *zonestatuses: an array ofgooglecomputezonestatus *availablecpuplatforms: an array ofgooglecomputezone` availablecpuplatforms

Filter Criteria

This resource supports all of the above properties as filter criteria, which can be used with where as a block or a method.

GCP Permissions

Ensure the Compute Engine API is enabled for the current project.