From 401be538c3882e5fedc07b6cfe946fa5d5a5919e Mon Sep 17 00:00:00 2001 From: pratikmore0290 Date: Fri, 25 Oct 2024 00:28:55 +0000 Subject: [PATCH 1/6] feat(bigquery): Add example for creating a connection --- bigquery/bigquery_create_connection/main.tf | 26 +++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 bigquery/bigquery_create_connection/main.tf diff --git a/bigquery/bigquery_create_connection/main.tf b/bigquery/bigquery_create_connection/main.tf new file mode 100644 index 000000000..256a04a10 --- /dev/null +++ b/bigquery/bigquery_create_connection/main.tf @@ -0,0 +1,26 @@ +/** +* Copyright 2024 Google LLC +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +# [START bigquery_create_connection] +## This creates a cloud resource connection. +## Note: The cloud resource nested object has only one output only field - serviceAccountId. +resource "google_bigquery_connection" "connection" { + connection_id = "my_connection" + project = "myproject1-381000" + location = "US" + cloud_resource {} +} +# [END bigquery_create_connection] From 2d70edcf2965852c10931ad360ceb565f7375ae6 Mon Sep 17 00:00:00 2001 From: pratikmore0290 Date: Fri, 25 Oct 2024 21:42:37 +0000 Subject: [PATCH 2/6] feat(bigquery): Add an example for creating a cloud resource connection --- .../main.tf | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 bigquery/bigquery_create_cloud_resource_connection/main.tf diff --git a/bigquery/bigquery_create_cloud_resource_connection/main.tf b/bigquery/bigquery_create_cloud_resource_connection/main.tf new file mode 100644 index 000000000..bf12859a4 --- /dev/null +++ b/bigquery/bigquery_create_cloud_resource_connection/main.tf @@ -0,0 +1,26 @@ +/** +* Copyright 2024 Google LLC +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +# [START bigquery_create_cloud_resource_connection] +## This creates a cloud resource connection. +## Note: The cloud resource nested object has only one output field - serviceAccountId. +resource "google_bigquery_connection" "connection" { + connection_id = "my_cloud_resource_connection" + project = "myproject1-381000" + location = "US" + cloud_resource {} +} +# [END bigquery_create_cloud_resource_connection] \ No newline at end of file From b0abfdb5431394df82d08d61ed5696a0a3ba68df Mon Sep 17 00:00:00 2001 From: pratikmore0290 Date: Fri, 25 Oct 2024 22:19:57 +0000 Subject: [PATCH 3/6] feat(bigquery): Add an example for creating a cloud resource connection --- bigquery/bigquery_create_cloud_resource_connection/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigquery/bigquery_create_cloud_resource_connection/main.tf b/bigquery/bigquery_create_cloud_resource_connection/main.tf index bf12859a4..b29526d55 100644 --- a/bigquery/bigquery_create_cloud_resource_connection/main.tf +++ b/bigquery/bigquery_create_cloud_resource_connection/main.tf @@ -23,4 +23,4 @@ resource "google_bigquery_connection" "connection" { location = "US" cloud_resource {} } -# [END bigquery_create_cloud_resource_connection] \ No newline at end of file +# [END bigquery_create_cloud_resource_connection] From 0b9e02a9da0298009ee5158ccb94f61119b9d32c Mon Sep 17 00:00:00 2001 From: pratikmore0290 Date: Fri, 25 Oct 2024 23:57:49 +0000 Subject: [PATCH 4/6] Add an example for creating a cloud resource connection --- bigquery/bigquery_create_connection/main.tf | 26 --------------------- 1 file changed, 26 deletions(-) delete mode 100644 bigquery/bigquery_create_connection/main.tf diff --git a/bigquery/bigquery_create_connection/main.tf b/bigquery/bigquery_create_connection/main.tf deleted file mode 100644 index 256a04a10..000000000 --- a/bigquery/bigquery_create_connection/main.tf +++ /dev/null @@ -1,26 +0,0 @@ -/** -* Copyright 2024 Google LLC -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -# [START bigquery_create_connection] -## This creates a cloud resource connection. -## Note: The cloud resource nested object has only one output only field - serviceAccountId. -resource "google_bigquery_connection" "connection" { - connection_id = "my_connection" - project = "myproject1-381000" - location = "US" - cloud_resource {} -} -# [END bigquery_create_connection] From 7ed16a8886f189493254740dcce7e92e231f628c Mon Sep 17 00:00:00 2001 From: pratikmore0290 Date: Mon, 28 Oct 2024 20:05:31 +0000 Subject: [PATCH 5/6] Add an example for creating a cloud resource connection --- .../main.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename bigquery/{bigquery_create_cloud_resource_connection => bigquery_create_connection_cloud_resource}/main.tf (89%) diff --git a/bigquery/bigquery_create_cloud_resource_connection/main.tf b/bigquery/bigquery_create_connection_cloud_resource/main.tf similarity index 89% rename from bigquery/bigquery_create_cloud_resource_connection/main.tf rename to bigquery/bigquery_create_connection_cloud_resource/main.tf index b29526d55..e3c0b3934 100644 --- a/bigquery/bigquery_create_cloud_resource_connection/main.tf +++ b/bigquery/bigquery_create_connection_cloud_resource/main.tf @@ -14,7 +14,7 @@ * limitations under the License. */ -# [START bigquery_create_cloud_resource_connection] +# [START bigquery_create_connection_cloud_resource] ## This creates a cloud resource connection. ## Note: The cloud resource nested object has only one output field - serviceAccountId. resource "google_bigquery_connection" "connection" { @@ -23,4 +23,4 @@ resource "google_bigquery_connection" "connection" { location = "US" cloud_resource {} } -# [END bigquery_create_cloud_resource_connection] +# [END bigquery_create_connection_cloud_resource] From 5205a40b20d2b5f5c4c23b929d08e2aea3029ebd Mon Sep 17 00:00:00 2001 From: pratikmore0290 Date: Tue, 5 Nov 2024 21:54:35 +0000 Subject: [PATCH 6/6] Add an example for creating a cloud resource connection --- .../main.tf | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/bigquery/bigquery_create_connection_cloud_resource/main.tf b/bigquery/bigquery_create_connection_cloud_resource/main.tf index e3c0b3934..799879833 100644 --- a/bigquery/bigquery_create_connection_cloud_resource/main.tf +++ b/bigquery/bigquery_create_connection_cloud_resource/main.tf @@ -14,13 +14,26 @@ * limitations under the License. */ +# [START bigquery_create_connection_cloud_resource_iam] # [START bigquery_create_connection_cloud_resource] -## This creates a cloud resource connection. -## Note: The cloud resource nested object has only one output field - serviceAccountId. -resource "google_bigquery_connection" "connection" { + +# This queries the provider for project information. +data "google_project" "default" {} + +# This creates a cloud resource connection in the US region named my_cloud_resource_connection. +# Note: The cloud resource nested object has only one output field - serviceAccountId. +resource "google_bigquery_connection" "default" { connection_id = "my_cloud_resource_connection" - project = "myproject1-381000" + project = data.google_project.default.project_id location = "US" cloud_resource {} } # [END bigquery_create_connection_cloud_resource] + +## This grants IAM role access to the service account of the connection created in the previous step. +resource "google_project_iam_member" "connectionPermissionGrant" { + project = data.google_project.default.project_id + role = "roles/storage.objectViewer" + member = "serviceAccount:${google_bigquery_connection.default.cloud_resource[0].service_account_id}" +} +# [END bigquery_create_connection_cloud_resource_iam]