google_storage_bucket_objects resource
Use the google_storage_bucket_objects InSpec audit resource to to test a Google Cloud BucketObject resource.
Examples
describe google_storage_bucket_objects(bucket: 'bucket-with-object') do
its('object_names') { should include 'image1' }
its('count') { should be <= 10 }
end
Test that there are no more than a specified number of storage buckets for the project
describe google_storage_bucket_objects(bucket: 'bucket-name') do
its('count') { should be <= 100 }
end
Test that an expected named bucket is available
describe google_storage_bucket_objects(bucket: 'bucket-name') do
its('object_buckets'){ should include 'my_expected_bucket' }
end
Test that an expected named bucket is available
describe google_storage_bucket_objects(bucket: 'bucket-name') do
its('object_names'){ should include 'my_expected_object' }
end
Test a filtered group of bucket objects created within the last 24hrs
describe google_storage_bucket_objects(bucket: 'bucket-name').where(object_created_time > Time.now - 60*60*24) do
it { should exist }
end
Properties
Properties that can be accessed from the google_storage_bucket_objects resource:
See google_storage_bucket_object for more detailed information.
object_buckets: an array ofgoogle_storage_bucket_objectbucketobjects: an array ofgoogle_storage_bucket_objectobjectcontent_types: an array ofgoogle_storage_bucket_objectcontent_typecrc32cs: an array ofgoogle_storage_bucket_objectcrc32cetags: an array ofgoogle_storage_bucket_objectetaggenerations: an array ofgoogle_storage_bucket_objectgenerationids: an array ofgoogle_storage_bucket_objectidmd5_hashes: an array ofgoogle_storage_bucket_objectmd5_hashmedia_links: an array ofgoogle_storage_bucket_objectmedia_linkmetagenerations: an array ofgoogle_storage_bucket_objectmetagenerationobject_names: an array ofgoogle_storage_bucket_objectnamesizes: an array ofgoogle_storage_bucket_objectsizestorage_classes: an array ofgoogle_storage_bucket_objectstorage_classobject_created_times: an array ofgoogle_storage_bucket_objecttime_createdtime_deleteds: an array ofgoogle_storage_bucket_objecttime_deletedtime_storage_class_updateds: an array ofgoogle_storage_bucket_objecttime_storage_class_updatedtime_updateds: an array ofgoogle_storage_bucket_objecttime_updated
Filter criteria
This resource supports all of the above properties as filter criteria, which can be used
with where as a block or a method.
GCP permissions
Ensure the Google Cloud Storage is enabled for the current project.