创建 Cloud SQL for SQL Server 实例克隆

使用 Terraform 创建 Cloud SQL for SQL Server 实例的克隆

代码示例

Terraform

如需了解如何应用或移除 Terraform 配置,请参阅基本 Terraform 命令。 如需了解详情,请参阅 Terraform 提供程序参考文档

resource "google_sql_database_instance" "source" {
  name             = "sqlserver-instance-source-name"
  region           = "us-central1"
  database_version = "SQLSERVER_2017_STANDARD"
  root_password    = "INSERT-PASSWORD-HERE"
  settings {
    tier = "db-custom-2-7680"
  }
  # set `deletion_protection` to true, will ensure that one cannot accidentally delete this instance by
  # use of Terraform whereas `deletion_protection_enabled` flag protects this instance at the GCP level.
  deletion_protection = false
}

resource "google_sql_database_instance" "clone" {
  name             = "sqlserver-instance-clone-name"
  region           = "us-central1"
  database_version = "SQLSERVER_2017_STANDARD"
  root_password    = "INSERT-PASSWORD-HERE"
  clone {
    source_instance_name = google_sql_database_instance.source.id
  }
  # set `deletion_protection` to true, will ensure that one cannot accidentally delete this instance by
  # use of Terraform whereas `deletion_protection_enabled` flag protects this instance at the GCP level.
  deletion_protection = false
}

后续步骤

如需搜索和过滤其他 Google Cloud 产品的代码示例,请参阅Google Cloud 示例浏览器