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 of
googlecomputeinstancecreation_timestamp
*
deletionprotections: an array of
googlecomputeinstance` 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 of
googlecomputeinstanceid
*
labelfingerprints: an array of
googlecomputeinstance` 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 of
googlecomputeinstance` mincpuplatform
* `instancenames: an array of
googlecomputeinstancename
*
networkinterfaces: an array of
googlecomputeinstance` networkinterfaces
* schedulings
: an array of google_compute_instance
scheduling
* service_accounts
: an array of google_compute_instance
serviceaccounts
* `shieldedinstanceconfigs: an array of
googlecomputeinstance` shieldedinstanceconfig
* statuses
: an array of `googlecomputeinstancestatus
*
statusmessages: an array of
googlecomputeinstancestatus_message
*
tags: an array of
googlecomputeinstancetags
*
zones: an array of
googlecomputeinstance` 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.