Description
Cloud Storage’s logging block delivers usage and storage logs to a bucket. Configure Cloud Audit Logs separately for the API operations you need to audit, including Data Access events where required.
Potential impact
Usage logs can be late or incomplete. Missing request records can make unusual access harder to investigate.
Remediation
For details such as public-object reads, set logging.log_bucket to a destination in the same location and organization. Use the same project if there is no organization, and the same perimeter if VPC Service Controls applies. Grant cloud-storage-analytics@google.com the roles/storage.objectCreator role there. Restrict readers, set retention, and verify that logs arrive.
Examples
Choose available bucket names and create the log bucket separately. Both examples use force_destroy = true, which lets Terraform delete a nonempty bucket. Review that setting before applying.
Before
resource "google_storage_bucket" "example" {
name = "auto-expiring-bucket"
location = "US"
force_destroy = true
}
After
resource "google_storage_bucket" "example" {
name = "auto-expiring-bucket"
location = "US"
force_destroy = true
logging {
log_bucket = "example-logs-bucket"
}
}
The added logging block sends log files to example-logs-bucket.