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_instancecan_ip_forwardcpu_platforms: an array ofgoogle_compute_instancecpu_platformcreation_timestamps: an array ofgoogle_compute_instancecreation_timestampdeletion_protections: an array ofgoogle_compute_instancedeletion_protectiondisks: an array ofgoogle_compute_instancedisksguest_accelerators: an array ofgoogle_compute_instanceguest_acceleratorshostnames: an array ofgoogle_compute_instancehostnameinstance_ids: an array ofgoogle_compute_instanceidlabel_fingerprints: an array ofgoogle_compute_instancelabel_fingerprintlabels: an array ofgoogle_compute_instancelabelsmetadata: an array ofgoogle_compute_instancemetadatamachine_types: an array ofgoogle_compute_instancemachine_typemin_cpu_platforms: an array ofgoogle_compute_instancemin_cpu_platforminstance_names: an array ofgoogle_compute_instancenamenetwork_interfaces: an array ofgoogle_compute_instancenetwork_interfacesschedulings: an array ofgoogle_compute_instanceschedulingservice_accounts: an array ofgoogle_compute_instanceservice_accountsshielded_instance_configs: an array ofgoogle_compute_instanceshielded_instance_configstatuses: an array ofgoogle_compute_instancestatusstatus_messages: an array ofgoogle_compute_instancestatus_messagetags: an array ofgoogle_compute_instancetagszones: an array ofgoogle_compute_instancezone
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.