Skip to content

Commit 69da499

Browse files
committed
feat(bigquery): Add example for creating an authorized view
1 parent f077e22 commit 69da499

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

bigquery/bigquery_authorized_view_tutorial/main.tf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ resource "google_bigquery_table" "default" {
4242
deletion_protection = false # set to "true" in production
4343

4444
view {
45-
query = "SELECT item_id, avg(rating) FROM `chriscar9.movielens.movielens_1m` GROUP BY item_id ORDER BY item_id;"
45+
query = "SELECT item_id, avg(rating) FROM `myproject.movie_dataset.movie_ratings` GROUP BY item_id ORDER BY item_id;"
4646
use_legacy_sql = false
4747
}
4848
depends_on = [
@@ -55,8 +55,8 @@ Authorize the view to access the dataset that
5555
the query data originates from.
5656
*/
5757
resource "google_bigquery_dataset_access" "default" {
58-
project = "chriscar9"
59-
dataset_id = "movielens"
58+
project = "myproject"
59+
dataset_id = "movie_dataset"
6060

6161
view {
6262
project_id = google_bigquery_table.default.project
@@ -70,15 +70,15 @@ resource "google_bigquery_dataset_access" "default" {
7070

7171
/*
7272
Set the IAM policy for principals that can access
73-
the authorized view. These users should already have the
73+
the authorized view. These users should already have the
7474
roles/bigqueryUser role at the project level.
7575
*/
7676

7777
data "google_iam_policy" "default" {
7878
binding {
7979
role = "roles/bigquery.dataViewer"
8080
members = [
81-
"user:nbarn@google.com",
81+
"group:analysts@altostrat.com",
8282
]
8383
}
8484
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
apiVersion: blueprints.cloud.google.com/v1alpha1
16+
kind: BlueprintTest
17+
metadata:
18+
name: bigquery_authorized_view_tutorial
19+
spec:
20+
skip: true

0 commit comments

Comments
 (0)