Skip to content

Commit 04945f1

Browse files
psungrebecca-peteglasnt
authored andcommitted
feat(cloud_sql): add MySQL and PG samples for Read Pool (terraform-google-modules#886)
* Create test.yaml Add a `test.yaml` file for the `mysql_instance_replica_pool/main.tf` file. * Create main.tf Create `mysql_instance_replica_pool` folder. Add a MySQL `main.tf` file with Terraform samples related to the read pool feature. Operations include the following: * Create a read pool * Convert a read replica to a read pool * Convert a read pool to a read replica * Update read pool node count * Edit read pool configuration Add a corresponding `test.yaml` file. * Create test.yaml * Create main.tf * Delete cloud_sql/mysql_instance_replica_pool/test.yaml * Delete mysql_instance_replica_pool/main.tf * Create main.tf Create `postgres_instance_read_pool` folder. Add a PostgreSQL `main.tf` file with Terraform samples related to the read pool feature. Operations include the following: * Create a read pool * Convert a read replica to a read pool * Convert a read pool to a read replica * Update read pool node count * Edit read pool configuration Add a corresponding `test.yaml` file. * Create test.yaml * Retain only the creation sample * Move samples to cloud_sql subdir * Remove 'create' from names as it's implied * terraform fmt * remove CI aroundarounds, update metadata name * Update database versions to latest --------- Co-authored-by: Rebecca Peterson <[email protected]> Co-authored-by: Katie McLaughlin <[email protected]> Co-authored-by: Katie McLaughlin <[email protected]>
1 parent b3c96a8 commit 04945f1

File tree

4 files changed

+159
-0
lines changed

4 files changed

+159
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* Copyright 2025 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_read_pool]
18+
19+
resource "google_sql_database_instance" "primary" {
20+
name = "mysql-primary"
21+
database_version = "MYSQL_8_4"
22+
region = "europe-west4"
23+
24+
instance_type = "CLOUD_SQL_INSTANCE"
25+
26+
settings {
27+
tier = "db-perf-optimized-N-2"
28+
edition = "ENTERPRISE_PLUS"
29+
30+
backup_configuration {
31+
enabled = true
32+
binary_log_enabled = true
33+
}
34+
35+
ip_configuration {
36+
ipv4_enabled = true
37+
}
38+
}
39+
}
40+
41+
resource "google_sql_database_instance" "replica" {
42+
name = "mysql-replica"
43+
database_version = "MYSQL_8_4"
44+
region = "europe-west4"
45+
46+
master_instance_name = google_sql_database_instance.primary.name
47+
instance_type = "READ_POOL_INSTANCE"
48+
node_count = 2
49+
50+
settings {
51+
tier = "db-perf-optimized-N-2"
52+
edition = "ENTERPRISE_PLUS"
53+
54+
ip_configuration {
55+
ipv4_enabled = true
56+
}
57+
}
58+
}
59+
60+
# [END cloud_sql_mysql_read_pool]
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: cloudsql_mysql_instance_read_pool
19+
spec:
20+
skip: true
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/**
2+
* Copyright 2025 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_read_pool]
18+
19+
resource "google_sql_database_instance" "primary" {
20+
name = "postgres-primary"
21+
database_version = "POSTGRES_17"
22+
region = "europe-west4"
23+
24+
instance_type = "CLOUD_SQL_INSTANCE"
25+
26+
settings {
27+
tier = "db-perf-optimized-N-2"
28+
edition = "ENTERPRISE_PLUS"
29+
30+
backup_configuration {
31+
enabled = true
32+
}
33+
34+
ip_configuration {
35+
ipv4_enabled = true
36+
}
37+
}
38+
}
39+
40+
resource "google_sql_database_instance" "replica" {
41+
name = "postgres-replica"
42+
database_version = "POSTGRES_17"
43+
region = "europe-west4"
44+
45+
master_instance_name = google_sql_database_instance.primary.name
46+
instance_type = "READ_POOL_INSTANCE"
47+
node_count = 2
48+
49+
settings {
50+
tier = "db-perf-optimized-N-2"
51+
edition = "ENTERPRISE_PLUS"
52+
53+
ip_configuration {
54+
ipv4_enabled = true
55+
}
56+
}
57+
}
58+
59+
# [END cloud_sql_postgres_read_pool]
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: cloudsql_postgres_instance_read_pool
19+
spec:
20+
skip: true

0 commit comments

Comments
 (0)