Complete the code to enable data access logs for a BigQuery dataset.
resource "google_bigquery_dataset" "dataset" { dataset_id = "my_dataset" project = "my_project" location = "US" access_logs_config { [1] = true } }
The correct attribute to enable data access logs in the BigQuery dataset resource is data_access_logs_enabled.
Complete the code to specify the log type for data access logs in Cloud Audit Logs.
resource "google_logging_project_sink" "data_access_sink" { name = "data-access-logs" destination = "storage.googleapis.com/my-bucket" filter = "logName:[1]" }
The filter for data access logs uses the log name cloudaudit.googleapis.com/data_access.
Fix the error in the IAM policy binding to allow logging service account to write data access logs.
resource "google_project_iam_member" "logging_writer" { project = "my_project" role = "roles/logging.[1]" member = "serviceAccount:logging@my_project.iam.gserviceaccount.com" }
The correct role for allowing logging write access is roles/logging.logWriter, but in the code the role is specified after 'roles/logging.' so only 'logWriter' is needed as the blank.
Fill both blanks to configure a sink that exports data access logs to a Pub/Sub topic.
resource "google_logging_project_sink" "data_access_sink" { name = "data-access-logs" destination = "pubsub.googleapis.com/[1]" filter = "logName:[2]" }
The destination for Pub/Sub sinks uses the topic path like 'projects/my-project/topics/my-topic'. The filter for data access logs uses 'cloudaudit.googleapis.com/data_access'.
Fill all three blanks to create a BigQuery dataset with data access logs enabled and a sink exporting logs to Cloud Storage.
resource "google_bigquery_dataset" "dataset" { dataset_id = [1] project = [2] location = "US" access_logs_config { data_access_logs_enabled = true } } resource "google_logging_project_sink" "sink" { name = "bq-data-access-logs" destination = "storage.googleapis.com/[3]" filter = "logName:cloudaudit.googleapis.com/data_access" }
The BigQuery dataset ID is 'my_dataset', the project is 'my_project', and the sink destination bucket is 'my-bucket'.