-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support BigQuery authorized routines (#6680)
* BigQuery: Added support for authorized routine * BigQuery: Added examples for authorized routine * Update mmv1/products/bigquery/terraform.yaml Co-authored-by: Stephen Lewis (Burrows) <[email protected]> * Update mmv1/templates/terraform/examples/bigquery_dataset_authorized_routine.tf.erb Co-authored-by: Stephen Lewis (Burrows) <[email protected]> * add legacy iam access to test case * remove legacy roles * correct variable names and values * replace - to _ * [wip]added hand written test * fix corrupted test * Update mmv1/third_party/terraform/tests/resource_bigquery_dataset_access_test.go Co-authored-by: Stephen Lewis (Burrows) <[email protected]> Co-authored-by: Stephen Lewis (Burrows) <[email protected]>
- Loading branch information
Showing
6 changed files
with
238 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
mmv1/templates/terraform/examples/bigquery_dataset_access_authorized_routine.tf.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
resource "google_bigquery_dataset" "public" { | ||
dataset_id = "<%= ctx[:vars]['public_dataset'] %>" | ||
description = "This dataset is public" | ||
} | ||
|
||
resource "google_bigquery_routine" "public" { | ||
dataset_id = google_bigquery_dataset.public.dataset_id | ||
routine_id = "<%= ctx[:vars]['public_routine'] %>" | ||
routine_type = "TABLE_VALUED_FUNCTION" | ||
language = "SQL" | ||
definition_body = <<-EOS | ||
SELECT 1 + value AS value | ||
EOS | ||
arguments { | ||
name = "value" | ||
argument_kind = "FIXED_TYPE" | ||
data_type = jsonencode({ "typeKind" = "INT64" }) | ||
} | ||
return_table_type = jsonencode({ "columns" = [ | ||
{ "name" = "value", "type" = { "typeKind" = "INT64" } }, | ||
] }) | ||
} | ||
|
||
resource "google_bigquery_dataset" "private" { | ||
dataset_id = "<%= ctx[:vars]['private_dataset'] %>" | ||
description = "This dataset is private" | ||
} | ||
|
||
resource "google_bigquery_dataset_access" "authorized_routine" { | ||
dataset_id = google_bigquery_dataset.private.dataset_id | ||
routine { | ||
project_id = google_bigquery_routine.public.project | ||
dataset_id = google_bigquery_routine.public.dataset_id | ||
routine_id = google_bigquery_routine.public.routine_id | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
mmv1/templates/terraform/examples/bigquery_dataset_authorized_routine.tf.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
resource "google_bigquery_dataset" "public" { | ||
dataset_id = "<%= ctx[:vars]['public_dataset'] %>" | ||
description = "This dataset is public" | ||
} | ||
|
||
resource "google_bigquery_routine" "public" { | ||
dataset_id = google_bigquery_dataset.public.dataset_id | ||
routine_id = "<%= ctx[:vars]['public_routine'] %>" | ||
routine_type = "TABLE_VALUED_FUNCTION" | ||
language = "SQL" | ||
definition_body = <<-EOS | ||
SELECT 1 + value AS value | ||
EOS | ||
arguments { | ||
name = "value" | ||
argument_kind = "FIXED_TYPE" | ||
data_type = jsonencode({ "typeKind" = "INT64" }) | ||
} | ||
return_table_type = jsonencode({ "columns" = [ | ||
{ "name" = "value", "type" = { "typeKind" = "INT64" } }, | ||
] }) | ||
} | ||
|
||
resource "google_bigquery_dataset" "private" { | ||
dataset_id = "<%= ctx[:vars]['private_dataset'] %>" | ||
description = "This dataset is private" | ||
access { | ||
role = "OWNER" | ||
user_by_email = "<%= ctx[:test_env_vars]['service_account'] %>" | ||
} | ||
access { | ||
routine { | ||
project_id = google_bigquery_routine.public.project | ||
dataset_id = google_bigquery_routine.public.dataset_id | ||
routine_id = google_bigquery_routine.public.routine_id | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters