Skip to content

Conversation

@ccarpentiere
Copy link
Contributor

Description

Fixes b/361168902

Note: If you are not associated with Google, open an issue for discussion before submitting a pull request.

Checklist

Readiness

  • Yes, merge this PR after it is approved
  • No, don't merge this PR after it is approved

Style

Testing

Intended location

API enablement

  • If the sample needs an API enabled to pass testing, I have added the service to the Test setup file

Review

  • If this sample adds a new directory, I have added codeowners to the CODEOWNERS file

@ccarpentiere ccarpentiere requested review from a team as code owners July 14, 2025 21:13
@snippet-bot
Copy link

snippet-bot bot commented Jul 14, 2025

Here is the summary of changes.

You are about to add 1 region tag.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

dataset_id = "authdataset"
description = "Dataset for authorized view"
location = "us-west1"

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can remove this empty line

query = "SELECT item_id, avg(rating) FROM `myproject.movie_dataset.movie_ratings` GROUP BY item_id ORDER BY item_id;"
use_legacy_sql = false
}
depends_on = [
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since e.g. project and dataset_id accesses google_bigquery_dataset.default directly, Terraform can infer the dependency and we don't need depends_on explicitly, see https://developer.hashicorp.com/terraform/language/meta-arguments/depends_on.

Same in the other places in this example.

resource "google_bigquery_table_iam_policy" "default" {
project = google_bigquery_table.default.project
dataset_id = google_bigquery_dataset.default.dataset_id
table_id = "authview"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

google_bigquery_table.default.table_id

*/
resource "google_bigquery_table_iam_policy" "default" {
project = google_bigquery_table.default.project
dataset_id = google_bigquery_dataset.default.dataset_id
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

google_bigquery_table.default.dataset_id

Copy link
Contributor

@glasnt glasnt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nits, but some blockers.

Comment on lines 24 to 26
/*
Create a dataset to contain the authorized view.
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These comments can be useful, and if you want to keep the, I would suggest using single-line comments to reduce the lines of the demo, to make it more accessible/visible on the tutorial page.

If you want to present each resource in a different block in the codes, you can use region tags around each block.

Suggested change
/*
Create a dataset to contain the authorized view.
*/
# Create a dataset to contain the authorized view.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed in latest commit.

dataset_id = google_bigquery_dataset.default.dataset_id
table_id = "authview"
description = "View to authorize"
deletion_protection = false # set to "true" in production
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this sample is not being tested, remove this line and ensure the configuration is production ready. Deletion protection is true by default

Suggested change
deletion_protection = false # set to "true" in production

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed in latest commit.

Create a dataset to contain the authorized view.
*/
resource "google_bigquery_dataset" "default" {
dataset_id = "authdataset"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Query: is the dataset "authdataset", or "movie_dataset"? You're assigning dataset access to a different dataset later int his sample.

You can reference google_bigquery_dataset.default.dataset_id in other resources to ensure a consistent name.

It's helpful to clearly show which is the original dataset and which is the authorised view of the data with clear names (unsure what "movies" is in this context. )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I re-named the resources for clarity and tested again to make sure it works.

@glasnt glasnt merged commit 57fda1c into terraform-google-modules:main Jul 27, 2025
5 checks passed
niharika-98 pushed a commit to niharika-98/terraform-docs-samples that referenced this pull request Sep 7, 2025
…m-google-modules#872)

* feat(bigquery): Add example for creating an authorized view

* feat(bigquery): Add example for creating an authorized view

* feat(bigquery): Add example for creating an authorized view

* feat(bigquery): Add example for creating an authorized view

* feat(bigquery): Add example for creating an authorized view

---------

Co-authored-by: Katie McLaughlin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants