Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

# [START cloud_sql_sqlserver_instance_create_dr_replica]
resource "google_sql_database_instance" "original-primary" {
name = "sqlserver-primary-instance-name"
region = "us-east1"
# Specify a database version that supports Cloud SQL Enterprise Plus edition.
database_version = "SQLSERVER_2022_ENTERPRISE"
instance_type = "CLOUD_SQL_INSTANCE"
root_password = "INSERT-PASSWORD-HERE"
replica_names = ["sqlserver-replica-instance-name"]
settings {
tier = "db-perf-optimized-N-2"
edition = "ENTERPRISE_PLUS"
backup_configuration {
enabled = "true"
}
}
}

resource "google_sql_database_instance" "dr_replica" {
name = "sqlserver-replica-instance-name"
# Specify the original primary instance as the master instance.
master_instance_name = google_sql_database_instance.original-primary.name
# DR replica must be in a different region than the region of the primary instance.
region = "us-west2"
# DR replica must be the same database version as the primary instance.
database_version = "SQLSERVER_2022_ENTERPRISE"
instance_type = "READ_REPLICA_INSTANCE"
root_password = "INSERT-PASSWORD-HERE"
replica_configuration {
# Make the replica a cascadable replica.
cascadable_replica = true
}

settings {
# DR replica must be in the same tier as your primary instance and support Enterprise Plus edition.
tier = "db-perf-optimized-N-2"
edition = "ENTERPRISE_PLUS"
}
}
# [END cloud_sql_sqlserver_instance_create_dr_replica]
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: blueprints.cloud.google.com/v1alpha1
kind: BlueprintTest
metadata:
name: sqlserver_instance_switchover_create_dr_replica
spec:
skip: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

# [START cloud_sql_sqlserver_instance_switchover_begin]
resource "google_sql_database_instance" "original-primary" {
name = "sqlserver-primary-instance-name"
region = "us-east1"
database_version = "SQLSERVER_2022_ENTERPRISE"
instance_type = "CLOUD_SQL_INSTANCE"
root_password = "INSERT-PASSWORD-HERE"
replica_names = ["sqlserver-replica-instance-name"]
settings {
tier = "db-perf-optimized-N-2"
edition = "ENTERPRISE_PLUS"
backup_configuration {
enabled = "true"
}
}
}

resource "google_sql_database_instance" "dr_replica" {
name = "sqlserver-replica-instance-name"
# Remove or comment out the master_instance_name
# master_instance_name = google_sql_database_instance.original-primary.name
region = "us-west2"
database_version = "SQLSERVER_2022_ENTERPRISE"
# Change the instance type from "READ_REPLICA_INSTANCE" to "CLOUD_SQL_INSTANCE".
instance_type = "CLOUD_SQL_INSTANCE"
root_password = "INSERT-PASSWORD-HERE"
# Add the original primary to the replica_names list
replica_names = ["sqlserver-primary-instance-name"]
# Remove or comment out the replica_configuration section
# replica_configuration {
# cascadable_replica = true
# }

settings {
tier = "db-perf-optimized-N-2"
edition = "ENTERPRISE_PLUS"
}
}
# [END cloud_sql_sqlserver_instance_switchover_begin]
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: blueprints.cloud.google.com/v1alpha1
kind: BlueprintTest
metadata:
name: sqlserver_instance_switchover_switchover_begin
spec:
skip: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

# [START cloud_sql_sqlserver_instance_switchover_finish]
resource "google_sql_database_instance" "original-primary" {
name = "sqlserver-primary-instance-name"
# Set master_instance_name to the new primary instance, the original DR replica.
master_instance_name = "sqlserver-replica-instance-name"
region = "us-east1"
database_version = "SQLSERVER_2022_ENTERPRISE"
# Change the instance type from "CLOUD_SQL_INSTANCE" to "READ_REPLICA_INSTANCE".
instance_type = "READ_REPLICA_INSTANCE"
root_password = "INSERT-PASSWORD-HERE"
# Remove values from the replica_names field, but don't remove the field itself.
replica_names = []
# Add replica_configuration section and set cascadable_replica to true.
replica_configuration {
cascadable_replica = true
}
settings {
tier = "db-perf-optimized-N-2"
edition = "ENTERPRISE_PLUS"
backup_configuration {
enabled = "true"
}
}
}

resource "google_sql_database_instance" "dr_replica" {
name = "sqlserver-replica-instance-name"
region = "us-west2"
database_version = "SQLSERVER_2022_ENTERPRISE"
# Change the instance type from "READ_REPLICA_INSTANCE" to "CLOUD_SQL_INSTANCE".
instance_type = "CLOUD_SQL_INSTANCE"
root_password = "INSERT-PASSWORD-HERE"
# Add the original primary to the replica_names list
replica_names = ["sqlserver-primary-instance-name"]
settings {
tier = "db-perf-optimized-N-2"
edition = "ENTERPRISE_PLUS"
}
}
# [END cloud_sql_sqlserver_instance_switchover_finish]
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: blueprints.cloud.google.com/v1alpha1
kind: BlueprintTest
metadata:
name: sqlserver_instance_switchover_switchover_finish
spec:
skip: true