Open p13rr0m opened 2 years ago
This should be a working example. Instead of accessing a public table, I've added another private view with some data and select this view from the public view.
resource "google_bigquery_dataset" "private" {
dataset_id = "private_dataset"
}
resource "google_bigquery_table" "private" {
deletion_protection = false
dataset_id = google_bigquery_dataset.private.dataset_id
table_id = "private_table"
view {
query = "SELECT 1 AS value"
use_legacy_sql = false
}
}
resource "google_bigquery_dataset" "public" {
dataset_id = "public_dataset"
}
resource "google_bigquery_table" "public" {
deletion_protection = false
dataset_id = google_bigquery_dataset.public.dataset_id
table_id = "public_table"
view {
query = <<-EOS
SELECT
value
FROM
`${google_bigquery_table.private.project}.${google_bigquery_table.private.dataset_id}.${google_bigquery_table.private.table_id}`
EOS
use_legacy_sql = false
}
}
resource "google_bigquery_dataset_access" "access" {
dataset_id = google_bigquery_dataset.private.dataset_id
view {
project_id = google_bigquery_table.public.project
dataset_id = google_bigquery_dataset.public.dataset_id
table_id = google_bigquery_table.public.table_id
}
}
Community Note
Description
The example Bigquery Dataset Access View does not work. It creates a private dataset with no table and the view from the public dataset references a Looker table. I think it should actually create a new table in the private dataset and the view from the public dataset should reference the newly created table.
Google Provider Version
4.5.0
New or Affected Resource(s)
Documentation for
google_bigquery_dataset_access
b/300742529