Use the google_organization_policy InSpec audit resource to test constraints set on a GCP organization.
Google organization policies can restrict certain GCP services. For more information see https://cloud.google.com/resource-manager/docs/organization-policy/understanding-constraints
A google_organization_policy resource block declares the tests for a single GCP organization constraint identified by the pair of the name of the organization and the constraint:
describe google_organization_policy(name: 'organizations/123456', constraint: 'constraints/compute.disableGuestAttributesAccess') do
it { should exist }
its('boolean_policy.enforced') { should be true }
end
The following examples show how to use this InSpec audit resource.
describe google_organization_policy(name: 'organizations/123456', constraint: 'constraints/compute.disableGuestAttributesAccess') do
it { should exist }
its('boolean_policy.enforced') { should be true }
end
describe google_organization_policy(name: 'organizations/123456', constraint: 'constraints/someListConstraint') do
it { should exist }
its('list_policy.allowed_values') { should include 'included_val' }
its('list_policy.allowed_values') { should_not include 'excluded' }
its('list_policy.denied_values') { should include 'denied' }
end
update_timeboolean_policyenforcedlist_policyallowed_valuesdenied_valuesEnsure the Cloud Resource Manager API is enabled for the 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_organization_policy/