title | platform |
---|---|
About the google_organizations Resource |
gcp |
Use the google_organizations
InSpec audit resource to test properties of all, or a filtered group of, GCP
organizations.
A google_organizations
resource block collects GCP organizations then tests that group.
describe google_organizations do
it { should exist }
end
Use this InSpec resource to enumerate IDs then test in-depth using google_organization
.
google_organizations.names.each do |name|
describe google_organization(name: name) do
it { should exist }
its('lifecycle_state') { should eq "ACTIVE" }
end
end
The following examples show how to use this InSpec audit resource.
describe google_organizations do
its('count') { should be <= 100}
end
describe google_organizations do
its('names') { should include "organization/1234" }
end
describe google_organizations do
its('display_names') { should include "google.com" }
end
describe google_organizations do
its('lifecycle_state'){ should eq 'ACTIVE' }
end
google_organizations.where(display_name: /^goog/, lifecycle_state: 'ACTIVE').names.each do |name|
describe google_organization(name: name) do
it { should exist }
end
end
This resource supports the following filter criteria: name
; display_name
and lifecycle_state
. Any of these may be used with where
, as a block or as a method.
names
- an array of google_organization identifier stringsdisplay_names
- an array of google_organization display name stringslifecycle_state
- an array of google_organization lifecycle state strings
Ensure the Cloud Resource Manager API is enabled for the project.