title | platform |
---|---|
About the google_compute_region Resource |
gcp |
Use the google_compute_region
InSpec audit resource to test properties of a single GCP compute region.
A google_compute_region
resource block declares the tests for a single GCP region by project and name.
describe google_compute_region(project: 'chef-inspec-gcp', region: 'us-east1') do
its('name') { should match 'us-east1' }
end
The following examples show how to use this InSpec audit resource.
describe google_compute_region(project: 'chef-inspec-gcp', region: 'europe-west2') do
it { should exist }
end
describe google_compute_region(project: 'chef-inspec-gcp', region: 'europe-west2') do
its('status') { should eq 'UP' }
# or equivalently
it { should be_up }
end
describe google_compute_region(project: 'chef-inspec-gcp', region: "asia-east1") do
its('id') { should eq 1220 }
end
describe google_compute_region(project: 'chef-inspec-gcp', region: "asia-east1") do
its('zones') { should include "https://www.googleapis.com/compute/v1/projects/spaterson-project/zones/asia-east1-a" }
end
describe google_compute_region(project: 'chef-inspec-gcp', region: "asia-east1") do
its('zone_names') { should include "asia-east1-a" }
end
The zone_names
property is also useful for subsequently looping over associated google_compute_zone
resources. For example:
google_compute_region(project: 'chef-inspec-gcp', region: "asia-east1").zone_names.each do |zone_name|
describe google_compute_zone(project: 'chef-inspec-gcp', name: zone_name) do
it { should be_up }
end
end
creation_timestamp
,description
,id
,kind
,name
,quotas
,status
,zones
,zone_names
Ensure the Compute Engine API is enabled for the project where the resource is located.