Skip to content

Commit b3c49e9

Browse files
committed
feat(cloud_sql): add disabling psc on PSA+PSC instances examples
1 parent 1cfc3de commit b3c49e9

File tree

3 files changed

+81
-0
lines changed

3 files changed

+81
-0
lines changed

cloud_sql/mysql_instance_psa_psc/main.tf

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,28 @@ resource "google_compute_forwarding_rule" "default" {
9191

9292
# [END cloud_sql_mysql_instance_psa_psc_parent_tag]
9393

94+
// Configure a Cloud SQL MySQL instance with Private Service Connect disabled.
95+
# [START cloud_sql_mysql_instance_disable_psc_instance]
96+
resource "google_sql_database_instance" "disable_psc_example" {
97+
name = "mysql-disable-psc-example"
98+
region = "us-central1"
99+
database_version = "MYSQL_8_0"
100+
101+
depends_on = [google_service_networking_connection.default]
102+
103+
settings {
104+
tier = "db-f1-micro"
105+
ip_configuration {
106+
psc_config {
107+
psc_enabled = false
108+
allowed_consumer_projects = [] # clear consumer projects
109+
}
110+
ipv4_enabled = false
111+
private_network = google_compute_network.peering_network.id
112+
}
113+
}
114+
# set `deletion_protection` to true, will ensure that one cannot accidentally delete this instance by
115+
# use of Terraform whereas `deletion_protection_enabled` flag protects this instance at the GCP level.
116+
deletion_protection = false
117+
}
118+
# [END cloud_sql_mysql_instance_disable_psc_instance]

cloud_sql/postgres_instance_psa_psc/main.tf

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,33 @@ resource "google_compute_forwarding_rule" "default" {
9494
}
9595

9696
# [END cloud_sql_postgres_instance_psa_psc_parent_tag]
97+
98+
// Configure a Cloud SQL Postgres instance with Private Service Connect disabled.
99+
# [START cloud_sql_postgres_instance_disable_psc_instance]
100+
resource "google_sql_database_instance" "disable_psc_example" {
101+
name = "postgres-disable-psc-example"
102+
region = "us-central1"
103+
database_version = "POSTGRES_17"
104+
105+
depends_on = [google_service_networking_connection.default]
106+
107+
settings {
108+
tier = "db-custom-2-7680"
109+
availability_type = "REGIONAL"
110+
backup_configuration {
111+
enabled = true
112+
}
113+
ip_configuration {
114+
psc_config {
115+
psc_enabled = false
116+
allowed_consumer_projects = [] # clear consumer projects
117+
}
118+
ipv4_enabled = false
119+
private_network = google_compute_network.peering_network.id
120+
}
121+
}
122+
# set `deletion_protection` to true, will ensure that one cannot accidentally delete this instance by
123+
# use of Terraform whereas `deletion_protection_enabled` flag protects this instance at the GCP level.
124+
deletion_protection = false # Set to "true" to prevent destruction of the resource
125+
}
126+
# [END cloud_sql_postgres_instance_disable_psc_instance]

cloud_sql/sqlserver_instance_psa_psc/main.tf

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,29 @@ resource "google_compute_forwarding_rule" "default" {
9292

9393
# [END cloud_sql_sqlserver_instance_psa_psc_parent_tag]
9494

95+
// Configure a Cloud SQL SQL server instance with Private Service Connect disabled.
96+
# [START cloud_sql_sqlserver_instance_disable_psc_instance]
97+
resource "google_sql_database_instance" "disable_psc_example" {
98+
name = "sqlserver-disable-psc-example"
99+
region = "us-central1"
100+
database_version = "SQLSERVER_2019_STANDARD"
101+
root_password = "INSERT-PASSWORD-HERE"
102+
103+
depends_on = [google_service_networking_connection.default]
104+
105+
settings {
106+
tier = "db-custom-2-7680"
107+
ip_configuration {
108+
psc_config {
109+
psc_enabled = false
110+
allowed_consumer_projects = [] # clear consumer projects
111+
}
112+
ipv4_enabled = false
113+
private_network = google_compute_network.peering_network.id
114+
}
115+
}
116+
# set `deletion_protection` to true, will ensure that one cannot accidentally delete this instance by
117+
# use of Terraform whereas `deletion_protection_enabled` flag protects this instance at the GCP level.
118+
deletion_protection = false
119+
}
120+
# [END cloud_sql_sqlserver_instance_disable_psc_instance]

0 commit comments

Comments
 (0)