google_compute_instances resource
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 google_compute_instance for more detailed information.
can_ip_forwards
: an array ofgoogle_compute_instance
can_ip_forwardcpu_platforms
: an array ofgoogle_compute_instance
cpu_platformcreation_timestamps
: an array ofgoogle_compute_instance
creation_timestampdeletion_protections
: an array ofgoogle_compute_instance
deletion_protectiondisks
: an array ofgoogle_compute_instance
disksguest_accelerators
: an array ofgoogle_compute_instance
guest_acceleratorshostnames
: an array ofgoogle_compute_instance
hostnameinstance_ids
: an array ofgoogle_compute_instance
idlabel_fingerprints
: an array ofgoogle_compute_instance
label_fingerprintlabels
: an array ofgoogle_compute_instance
labelsmetadata
: an array ofgoogle_compute_instance
metadatamachine_types
: an array ofgoogle_compute_instance
machine_typemin_cpu_platforms
: an array ofgoogle_compute_instance
min_cpu_platforminstance_names
: an array ofgoogle_compute_instance
namenetwork_interfaces
: an array ofgoogle_compute_instance
network_interfacesschedulings
: an array ofgoogle_compute_instance
schedulingservice_accounts
: an array ofgoogle_compute_instance
service_accountsshielded_instance_configs
: an array ofgoogle_compute_instance
shielded_instance_configstatuses
: an array ofgoogle_compute_instance
statusstatus_messages
: an array ofgoogle_compute_instance
status_messagetags
: an array ofgoogle_compute_instance
tagszones
: an array ofgoogle_compute_instance
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.