Syntax

A google_compute_instances is used to test a Google Instance resource

Beta Resource

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

Examples


describe google_compute_instances(project: 'chef-gcp-inspec', zone: 'zone') do
  its('instance_names') { should include 'inspec-instance' }
end

Test that there are no more than a specified number of instances in the project and zone

describe google_compute_instances(project: 'chef-inspec-gcp',  zone: 'europe-west2-a') do
  its('count') { should be <= 100}
end

Test the exact number of instances in the project and zone

describe google_compute_instances(project: 'chef-inspec-gcp',  zone: 'europe-west2-a') do
  its('instance_ids.count') { should cmp 9 }
end

Test that an instance with a particular name exists in the project and zone

describe google_compute_instances(project: 'chef-inspec-gcp',  zone: 'europe-west2-a') do
  its('instance_names') { should include "my-favourite-instance" }
end

Properties

Properties that can be accessed from the google_compute_instances resource:

See googlecomputeinstance.md for more detailed information * can_ip_forwards: an array of google_compute_instance canipforward * cpu_platforms: an array of google_compute_instance cpuplatform * `creationtimestamps: an array ofgooglecomputeinstancecreation_timestamp *deletionprotections: an array ofgooglecomputeinstance` deletionprotection * disks: an array of google_compute_instance disks * guest_accelerators: an array of google_compute_instance guestaccelerators * hostnames: an array of `googlecomputeinstancehostname *instanceids: an array ofgooglecomputeinstanceid *labelfingerprints: an array ofgooglecomputeinstance` labelfingerprint * labels: an array of google_compute_instance labels * metadata: an array of google_compute_instance metadata * machine_types: an array of google_compute_instance machinetype * `mincpuplatforms: an array ofgooglecomputeinstance` mincpuplatform * `instancenames: an array ofgooglecomputeinstancename *networkinterfaces: an array ofgooglecomputeinstance` networkinterfaces * schedulings: an array of google_compute_instance scheduling * service_accounts: an array of google_compute_instance serviceaccounts * `shieldedinstanceconfigs: an array ofgooglecomputeinstance` shieldedinstanceconfig * statuses: an array of `googlecomputeinstancestatus *statusmessages: an array ofgooglecomputeinstancestatus_message *tags: an array ofgooglecomputeinstancetags *zones: an array ofgooglecomputeinstance` zone

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.