On this page
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-favorite-instance" }
end
Properties
Properties that can be accessed from the google_compute_instances resource:
See the google_compute_instance resource for more information.
-
can_ip_forwards -
an array of
google_compute_instancecan_ip_forward -
cpu_platforms -
an array of
google_compute_instancecpu_platform -
creation_timestamps -
an array of
google_compute_instancecreation_timestamp -
deletion_protections -
an array of
google_compute_instancedeletion_protection -
disks -
an array of
google_compute_instancedisks -
guest_accelerators -
an array of
google_compute_instanceguest_accelerators -
hostnames -
an array of
google_compute_instancehostname -
instance_ids -
an array of
google_compute_instanceid -
label_fingerprints -
an array of
google_compute_instancelabel_fingerprint -
labels -
an array of
google_compute_instancelabels -
metadata -
an array of
google_compute_instancemetadata -
machine_types -
an array of
google_compute_instancemachine_type -
min_cpu_platforms -
an array of
google_compute_instancemin_cpu_platform -
instance_names -
an array of
google_compute_instancename -
network_interfaces -
an array of
google_compute_instancenetwork_interfaces -
schedulings -
an array of
google_compute_instancescheduling -
service_accounts -
an array of
google_compute_instanceservice_accounts -
shielded_instance_configs -
an array of
google_compute_instanceshielded_instance_config -
statuses -
an array of
google_compute_instancestatus -
status_messages -
an array of
google_compute_instancestatus_message -
tags -
an array of
google_compute_instancetags -
zones -
an array of
google_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.
© Chef Software, Inc.
Licensed under the Creative Commons Attribution 3.0 Unported License.
The Chef™ Mark and Chef Logo are either registered trademarks/service marks or trademarks/servicemarks of Chef, in the United States and other countries and are used with Chef Inc's permission.
We are not affiliated with, endorsed or sponsored by Chef Inc.
https://docs.chef.io/inspec/resources/google_compute_instances/