title | platform |
---|---|
About the google_storage_bucket_objects Resource |
gcp |
Use the google_storage_bucket_objects
InSpec audit resource to test properties of a GCP storage bucket objects.
A google_storage_bucket_objects
resource block collects GCP bucket objects by project then tests that group.
describe google_storage_bucket_objects(bucket: 'bucket-name') do
it { should exist }
end
Use this InSpec resource to enumerate IDs then test in-depth using google_storage_bucket_object
.
google_storage_bucket_objects(bucket: 'bucket-name').object_names.each do |object_name|
describe google_storage_bucket_object(bucket: bucket_name, object: object_name) do
it { should exist }
end
end
The following examples show how to use this InSpec audit resource.
describe google_storage_bucket_objects(bucket: 'bucket-name') do
its('count') { should be <= 100 }
end
describe google_storage_bucket_objects(bucket: 'bucket-name') do
its('object_buckets'){ should include 'my_expected_bucket' }
end
describe google_storage_bucket_objects(bucket: 'bucket-name') do
its('object_names'){ should include 'my_expected_object' }
end
describe google_storage_bucket_objects(bucket: 'bucket-name').where(object_created_time > Time.now - 60*60*24) do
it { should exist }
end
This resource supports the following filter criteria: object_bucket
; object_name
and object_created_time
. Any of these may be used with where
, as a block or as a method.
object_buckets
- an array of google_storage_bucket identifier stringsobject_names
- an array of google_storage_bucket_object name stringsobject_created_times
- an array of time created Time objects
<br
Ensure the Google Cloud Storage API is enabled.