title | platform |
---|---|
About the google_logging_project_sinks Resource |
gcp |
Use the google_logging_project_sinks
InSpec audit resource to test properties of all, or a filtered group of, GCP compute project logging sinks for a project.
A google_logging_project_sinks
resource block collects GCP project logging sinks by project then tests that group.
describe google_logging_project_sinks(project: 'chef-inspec-gcp') do
it { should exist }
end
Use this InSpec resource to enumerate IDs then test in-depth using google_logging_project_sink
.
google_logging_project_sinks(project: 'chef-inspec-gcp').sink_names.each do |sink_name|
describe google_logging_project_sink(project: 'chef-inspec-gcp', sink: sink_name) do
it { should exist }
end
end
The following examples show how to use this InSpec audit resource.
describe google_logging_project_sinks(project: 'chef-inspec-gcp') do
its('count') { should be <= 100}
end
describe google_logging_project_sinks(project: 'chef-inspec-gcp') do
its('sink_names') { should include "my-sink" }
end
describe google_logging_project_sinks(project: 'chef-inspec-gcp') do
its('sink_destinations') { should include "storage.googleapis.com/a-logging-bucket" }
end
google_logging_project_sinks(project: 'chef-inspec-gcp').where(sink_name: /project/).sink_names.each do |sink_name|
describe google_logging_project_sink(project: 'chef-inspec-gcp', sink: sink_name) do
its('writer_identity') { should eq "serviceAccount:my-logging-service-account.iam.gserviceaccount.com" }
end
end
This resource supports the following filter criteria: sink_name
; sink_filter
and sink_destination
. Any of these may be used with where
, as a block or as a method.
sink_names
- an array of google_logging_project_sink name stringssink_destinations
- an array of google_logging_project_sink destinationssink_filters
- an array of google_logging_project_sink filters
Ensure the Stackdriver Logging API is enabled for the project.