Skip to content

Commit d244fbc

Browse files
authored
Merge branch 'main' into read-pool-samples
2 parents 1ff476b + 55db0f9 commit d244fbc

File tree

8 files changed

+229
-2
lines changed

8 files changed

+229
-2
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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_sqlserver_instance_create_dr_replica]
18+
resource "google_sql_database_instance" "original-primary" {
19+
name = "sqlserver-primary-instance-name"
20+
region = "us-east1"
21+
# Specify a database version that supports Cloud SQL Enterprise Plus edition.
22+
database_version = "SQLSERVER_2022_ENTERPRISE"
23+
instance_type = "CLOUD_SQL_INSTANCE"
24+
root_password = "INSERT-PASSWORD-HERE"
25+
replica_names = ["sqlserver-replica-instance-name"]
26+
settings {
27+
tier = "db-perf-optimized-N-2"
28+
edition = "ENTERPRISE_PLUS"
29+
backup_configuration {
30+
enabled = "true"
31+
}
32+
}
33+
}
34+
35+
resource "google_sql_database_instance" "dr_replica" {
36+
name = "sqlserver-replica-instance-name"
37+
# Specify the original primary instance as the master instance.
38+
master_instance_name = google_sql_database_instance.original-primary.name
39+
# DR replica must be in a different region than the region of the primary instance.
40+
region = "us-west2"
41+
# DR replica must be the same database version as the primary instance.
42+
database_version = "SQLSERVER_2022_ENTERPRISE"
43+
instance_type = "READ_REPLICA_INSTANCE"
44+
root_password = "INSERT-PASSWORD-HERE"
45+
replica_configuration {
46+
# Make the replica a cascadable replica.
47+
cascadable_replica = true
48+
}
49+
50+
settings {
51+
# DR replica must be in the same tier as your primary instance and support Enterprise Plus edition.
52+
tier = "db-perf-optimized-N-2"
53+
edition = "ENTERPRISE_PLUS"
54+
}
55+
}
56+
# [END cloud_sql_sqlserver_instance_create_dr_replica]
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: sqlserver_instance_switchover_create_dr_replica
19+
spec:
20+
skip: true
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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_sqlserver_instance_switchover_begin]
18+
resource "google_sql_database_instance" "original-primary" {
19+
name = "sqlserver-primary-instance-name"
20+
region = "us-east1"
21+
database_version = "SQLSERVER_2022_ENTERPRISE"
22+
instance_type = "CLOUD_SQL_INSTANCE"
23+
root_password = "INSERT-PASSWORD-HERE"
24+
replica_names = ["sqlserver-replica-instance-name"]
25+
settings {
26+
tier = "db-perf-optimized-N-2"
27+
edition = "ENTERPRISE_PLUS"
28+
backup_configuration {
29+
enabled = "true"
30+
}
31+
}
32+
}
33+
34+
resource "google_sql_database_instance" "dr_replica" {
35+
name = "sqlserver-replica-instance-name"
36+
# Remove or comment out the master_instance_name
37+
# master_instance_name = google_sql_database_instance.original-primary.name
38+
region = "us-west2"
39+
database_version = "SQLSERVER_2022_ENTERPRISE"
40+
# Change the instance type from "READ_REPLICA_INSTANCE" to "CLOUD_SQL_INSTANCE".
41+
instance_type = "CLOUD_SQL_INSTANCE"
42+
root_password = "INSERT-PASSWORD-HERE"
43+
# Add the original primary to the replica_names list
44+
replica_names = ["sqlserver-primary-instance-name"]
45+
# Remove or comment out the replica_configuration section
46+
# replica_configuration {
47+
# cascadable_replica = true
48+
# }
49+
50+
settings {
51+
tier = "db-perf-optimized-N-2"
52+
edition = "ENTERPRISE_PLUS"
53+
}
54+
}
55+
# [END cloud_sql_sqlserver_instance_switchover_begin]
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: sqlserver_instance_switchover_switchover_begin
19+
spec:
20+
skip: true
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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_sqlserver_instance_switchover_finish]
18+
resource "google_sql_database_instance" "original-primary" {
19+
name = "sqlserver-primary-instance-name"
20+
# Set master_instance_name to the new primary instance, the original DR replica.
21+
master_instance_name = "sqlserver-replica-instance-name"
22+
region = "us-east1"
23+
database_version = "SQLSERVER_2022_ENTERPRISE"
24+
# Change the instance type from "CLOUD_SQL_INSTANCE" to "READ_REPLICA_INSTANCE".
25+
instance_type = "READ_REPLICA_INSTANCE"
26+
root_password = "INSERT-PASSWORD-HERE"
27+
# Remove values from the replica_names field, but don't remove the field itself.
28+
replica_names = []
29+
# Add replica_configuration section and set cascadable_replica to true.
30+
replica_configuration {
31+
cascadable_replica = true
32+
}
33+
settings {
34+
tier = "db-perf-optimized-N-2"
35+
edition = "ENTERPRISE_PLUS"
36+
backup_configuration {
37+
enabled = "true"
38+
}
39+
}
40+
}
41+
42+
resource "google_sql_database_instance" "dr_replica" {
43+
name = "sqlserver-replica-instance-name"
44+
region = "us-west2"
45+
database_version = "SQLSERVER_2022_ENTERPRISE"
46+
# Change the instance type from "READ_REPLICA_INSTANCE" to "CLOUD_SQL_INSTANCE".
47+
instance_type = "CLOUD_SQL_INSTANCE"
48+
root_password = "INSERT-PASSWORD-HERE"
49+
# Add the original primary to the replica_names list
50+
replica_names = ["sqlserver-primary-instance-name"]
51+
settings {
52+
tier = "db-perf-optimized-N-2"
53+
edition = "ENTERPRISE_PLUS"
54+
}
55+
}
56+
# [END cloud_sql_sqlserver_instance_switchover_finish]
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: sqlserver_instance_switchover_switchover_finish
19+
spec:
20+
skip: true

managedkafka/managedkafka_create_connector_bigquery_sink/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ resource "google_managed_kafka_connector" "example-bigquery-sink-connector" {
8080

8181
configs = {
8282
"name" = "my-bigquery-sink-connector"
83-
"project" = "GCP_PROJECT_ID"
83+
"project" = data.google_project.default.project_id
8484
"topics" = "GMK_TOPIC_ID"
8585
"tasks.max" = "3"
8686
"connector.class" = "com.wepay.kafka.connect.bigquery.BigQuerySinkConnector"

managedkafka/managedkafka_create_connector_pubsub_source/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ resource "google_managed_kafka_connector" "example-pubsub-source-connector" {
8484
"tasks.max" = "3"
8585
"kafka.topic" = "GMK_TOPIC_ID"
8686
"cps.subscription" = "CPS_SUBSCRIPTION_ID"
87-
"cps.project" = "GCP_PROJECT_ID"
87+
"cps.project" = data.google_project.default.project_id
8888
"value.converter" = "org.apache.kafka.connect.converters.ByteArrayConverter"
8989
"key.converter" = "org.apache.kafka.connect.storage.StringConverter"
9090
}

0 commit comments

Comments
 (0)