Skip to content

Commit f931c2d

Browse files
yyzou-botNimJay
andauthored
feat(cloud_sql): add creation of PSC SA instances examples (#860)
* feat(cloud_sql): add creation of PSC SA instances examples * dont change sqlserver test.yaml * fix: Fix lint issue in main.tf * fix: Update lint issue in main.tf --------- Co-authored-by: Nim Jayawardena <[email protected]>
1 parent 2eca451 commit f931c2d

File tree

6 files changed

+216
-0
lines changed

6 files changed

+216
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/**
2+
* Copyright 2022 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+
data "google_project" "project" {
18+
}
19+
20+
# [START vpc_mysql_instance_consumer_network]
21+
resource "google_compute_network" "consumer_network" {
22+
name = "consumer-network"
23+
auto_create_subnetworks = "true"
24+
}
25+
# [END vpc_mysql_instance_consumer_network]
26+
27+
# [START cloud_sql_mysql_instance_psc_sa]
28+
resource "google_sql_database_instance" "default" {
29+
name = "mysql-instance"
30+
region = "us-central1"
31+
database_version = "MYSQL_8_0"
32+
settings {
33+
tier = "db-f1-micro"
34+
availability_type = "REGIONAL"
35+
backup_configuration {
36+
enabled = true
37+
binary_log_enabled = true
38+
}
39+
ip_configuration {
40+
psc_config {
41+
psc_enabled = true
42+
allowed_consumer_projects = [] # Add consumer project IDs here.
43+
psc_auto_connections {
44+
consumer_network = google_compute_network.consumer_network.id
45+
consumer_service_project_id = data.google_project.project.project_id
46+
}
47+
}
48+
ipv4_enabled = false
49+
}
50+
}
51+
}
52+
# [END cloud_sql_mysql_instance_psc_sa]
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: sql_mysql_instance_psc_sa
19+
spec:
20+
skip: true
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/**
2+
* Copyright 2022 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+
data "google_project" "project" {
18+
}
19+
20+
# [START vpc_postgres_instance_consumer_network]
21+
resource "google_compute_network" "consumer_network" {
22+
name = "consumer-network"
23+
auto_create_subnetworks = "true"
24+
}
25+
# [END vpc_postgres_instance_consumer_network]
26+
27+
# [START cloud_sql_postgres_instance_psc_sa]
28+
resource "google_sql_database_instance" "default" {
29+
name = "postgres-instance"
30+
region = "us-central1"
31+
database_version = "POSTGRES_14"
32+
settings {
33+
tier = "db-custom-2-7680"
34+
availability_type = "REGIONAL"
35+
backup_configuration {
36+
enabled = true
37+
}
38+
ip_configuration {
39+
psc_config {
40+
psc_enabled = true
41+
allowed_consumer_projects = []
42+
psc_auto_connections {
43+
consumer_network = google_compute_network.consumer_network.id
44+
consumer_service_project_id = data.google_project.project.project_id
45+
}
46+
}
47+
ipv4_enabled = false
48+
}
49+
}
50+
}
51+
# [END cloud_sql_postgres_instance_psc_sa]
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: sql_postgres_instance_psc_sa
19+
spec:
20+
skip: true
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/**
2+
* Copyright 2022 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+
data "google_project" "project" {
18+
}
19+
20+
# [START vpc_sqlserver_instance_consumer_network]
21+
resource "google_compute_network" "consumer_network" {
22+
name = "consumer-network"
23+
auto_create_subnetworks = "true"
24+
}
25+
# [END vpc_sqlserver_instance_consumer_network]
26+
27+
# [START cloud_sql_sqlserver_instance_psc_sa]
28+
resource "google_sql_database_instance" "default" {
29+
name = "sqlserver-instance"
30+
region = "us-central1"
31+
database_version = "SQLSERVER_2019_ENTERPRISE"
32+
root_password = "INSERT-PASSWORD-HERE"
33+
settings {
34+
tier = "db-custom-2-7680"
35+
availability_type = "REGIONAL"
36+
backup_configuration {
37+
enabled = true
38+
start_time = "20:55"
39+
}
40+
ip_configuration {
41+
psc_config {
42+
psc_enabled = true
43+
allowed_consumer_projects = [] # Add consumer project IDs here.
44+
psc_auto_connections {
45+
consumer_network = google_compute_network.consumer_network.id
46+
consumer_service_project_id = data.google_project.project.project_id
47+
}
48+
}
49+
ipv4_enabled = false
50+
}
51+
}
52+
}
53+
# [END cloud_sql_sqlserver_instance_psc_sa]
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: sql_sqlserver_instance_psc_sa
19+
spec:
20+
skip: true

0 commit comments

Comments
 (0)