Skip to content

Commit 87c2d2d

Browse files
authored
Merge branch 'terraform-google-modules:main' into main
2 parents 67c58c7 + 33abdd5 commit 87c2d2d

File tree

10 files changed

+387
-1
lines changed

10 files changed

+387
-1
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/**
2+
* Copyright 2024 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
# [START cloud_sql_mysql_instance_iam_db_auth]
18+
# [START cloud_sql_mysql_instance_iam_db_auth_create_instance]
19+
# [START cloud_sql_mysql_instance_iam_db_auth_add_users]
20+
resource "google_sql_database_instance" "default" {
21+
name = "mysql-db-auth-instance-name-test"
22+
region = "us-west4"
23+
database_version = "MYSQL_8_0"
24+
settings {
25+
tier = "db-f1-micro"
26+
database_flags {
27+
name = "cloudsql_iam_authentication"
28+
value = "on"
29+
}
30+
}
31+
# set `deletion_protection` to true, will ensure that one cannot accidentally
32+
# delete this instance by use of Terraform whereas
33+
# `deletion_protection_enabled` flag protects this instance at the GCP level.
34+
deletion_protection = false
35+
}
36+
# [END cloud_sql_mysql_instance_iam_db_auth_create_instance]
37+
38+
# Specify the email address of the IAM user to add to the instance
39+
# This resource does not create a new IAM user account; this account must
40+
# already exist
41+
42+
resource "google_sql_user" "iam_user" {
43+
44+
instance = google_sql_database_instance.default.name
45+
type = "CLOUD_IAM_USER"
46+
}
47+
48+
# Create a new IAM service account
49+
50+
resource "google_service_account" "default" {
51+
account_id = "cloud-sql-mysql-sa"
52+
display_name = "Cloud SQL for MySQL Service Account"
53+
}
54+
55+
# Specify the email address of the IAM service account to add to the instance
56+
57+
resource "google_sql_user" "iam_service_account_user" {
58+
name = google_service_account.default.email
59+
instance = google_sql_database_instance.default.name
60+
type = "CLOUD_IAM_SERVICE_ACCOUNT"
61+
}
62+
# [END cloud_sql_mysql_instance_iam_db_auth_add_users]
63+
64+
# [START cloud_sql_mysql_instance_iam_db_grant_roles]
65+
data "google_project" "project" {
66+
}
67+
68+
resource "google_project_iam_binding" "cloud_sql_user" {
69+
project = data.google_project.project.project_id
70+
role = "roles/cloudsql.instanceUser"
71+
members = [
72+
73+
"serviceAccount:${google_service_account.default.email}"
74+
]
75+
}
76+
77+
resource "google_project_iam_binding" "cloud_sql_client" {
78+
project = data.google_project.project.project_id
79+
role = "roles/cloudsql.client"
80+
members = [
81+
82+
"serviceAccount:${google_service_account.default.email}"
83+
]
84+
}
85+
# [END cloud_sql_mysql_instance_iam_db_grant_roles]
86+
# [END cloud_sql_mysql_instance_iam_db_auth]
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright 2024 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: mysql_instance_iam_db_auth
19+
spec:
20+
skip: true
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/**
2+
* Copyright 2024 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
# [START cloud_sql_postgres_instance_iam_db_auth]
18+
# [START cloud_sql_postgres_instance_iam_db_auth_create_instance]
19+
# [START cloud_sql_postgres_instance_iam_db_auth_add_users]
20+
resource "google_sql_database_instance" "default" {
21+
name = "postgres-db-auth-instance-name-test"
22+
region = "us-west4"
23+
database_version = "POSTGRES_14"
24+
settings {
25+
tier = "db-custom-2-7680"
26+
database_flags {
27+
name = "cloudsql.iam_authentication"
28+
value = "on"
29+
}
30+
}
31+
# set `deletion_protection` to true, will ensure that one cannot accidentally
32+
# delete this instance by use of Terraform whereas
33+
# `deletion_protection_enabled` flag protects this instance at the GCP level.
34+
deletion_protection = false
35+
}
36+
# [END cloud_sql_postgres_instance_iam_db_auth_create_instance]
37+
38+
# Specify the email address of the IAM user to add to the instance
39+
# This resource does not create a new IAM user account; this account must
40+
# already exist
41+
42+
resource "google_sql_user" "iam_user" {
43+
44+
instance = google_sql_database_instance.default.name
45+
type = "CLOUD_IAM_USER"
46+
}
47+
48+
# Specify the email address of the IAM service account to add to the instance
49+
# This resource does not create a new IAM service account; this service account
50+
# must already exist
51+
52+
# Create a new IAM service account
53+
54+
resource "google_service_account" "default" {
55+
account_id = "cloud-sql-postgres-sa"
56+
display_name = "Cloud SQL for Postgres Service Account"
57+
}
58+
59+
resource "google_sql_user" "iam_service_account_user" {
60+
# Note: for PostgreSQL only, Google Cloud requires that you omit the
61+
# ".gserviceaccount.com" suffix
62+
# from the service account email due to length limits on database usernames.
63+
name = trimsuffix(google_service_account.default.email, ".gserviceaccount.com")
64+
instance = google_sql_database_instance.default.name
65+
type = "CLOUD_IAM_SERVICE_ACCOUNT"
66+
}
67+
# [END cloud_sql_postgres_instance_iam_db_auth_add_users]
68+
69+
# [START cloud_sql_postgres_instance_iam_db_grant_roles]
70+
data "google_project" "project" {
71+
}
72+
73+
resource "google_project_iam_binding" "cloud_sql_user" {
74+
project = data.google_project.project.project_id
75+
role = "roles/cloudsql.instanceUser"
76+
members = [
77+
78+
"serviceAccount:${google_service_account.default.email}"
79+
]
80+
}
81+
82+
resource "google_project_iam_binding" "cloud_sql_client" {
83+
project = data.google_project.project.project_id
84+
role = "roles/cloudsql.client"
85+
members = [
86+
87+
"serviceAccount:${google_service_account.default.email}"
88+
]
89+
}
90+
# [END cloud_sql_postgres_instance_iam_db_grant_roles]
91+
# [END cloud_sql_postgres_instance_iam_db_auth]
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright 2024 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: postgres_instance_iam_db_auth
19+
spec:
20+
skip: true

vertex_ai/workbench/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2023 Google LLC
2+
* Copyright 2024 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* Copyright 2024 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
18+
# [START aiplatform_workbench_create_metadata]
19+
resource "google_workbench_instance" "default" {
20+
name = "workbench-instance-example"
21+
location = "us-central1-a"
22+
23+
gce_setup {
24+
machine_type = "n1-standard-1"
25+
vm_image {
26+
project = "deeplearning-platform-release"
27+
family = "tf-latest-gpu"
28+
}
29+
metadata = {
30+
key = "value"
31+
}
32+
}
33+
}
34+
# [END aiplatform_workbench_create_metadata]
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* Copyright 2024 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
18+
# [START aiplatform_workbench_create_dataproc]
19+
resource "google_workbench_instance" "default" {
20+
name = "workbench-instance-example"
21+
location = "us-central1-a"
22+
23+
gce_setup {
24+
machine_type = "n1-standard-1"
25+
vm_image {
26+
project = "deeplearning-platform-release"
27+
family = "tf-latest-gpu"
28+
}
29+
metadata = {
30+
disable-mixer = "false"
31+
}
32+
}
33+
}
34+
# [END aiplatform_workbench_create_dataproc]
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* Copyright 2024 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
18+
# [START aiplatform_workbench_create_idle_shutdown]
19+
resource "google_workbench_instance" "default" {
20+
name = "workbench-instance-example"
21+
location = "us-central1-a"
22+
23+
gce_setup {
24+
machine_type = "n1-standard-1"
25+
vm_image {
26+
project = "deeplearning-platform-release"
27+
family = "tf-latest-gpu"
28+
}
29+
metadata = {
30+
idle-timeout-seconds = "10800"
31+
}
32+
}
33+
}
34+
# [END aiplatform_workbench_create_idle_shutdown]
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* Copyright 2024 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
18+
# [START aiplatform_workbench_deleted_metadata]
19+
resource "google_workbench_instance" "default" {
20+
name = "workbench-instance-example"
21+
location = "us-central1-a"
22+
23+
gce_setup {
24+
machine_type = "n1-standard-1"
25+
vm_image {
26+
project = "deeplearning-platform-release"
27+
family = "tf-latest-gpu"
28+
}
29+
metadata = {
30+
}
31+
}
32+
}
33+
# [END aiplatform_workbench_deleted_metadata]

0 commit comments

Comments
 (0)