0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

cloud sqlでレプリケーションをTerraformで作りたい

Last updated at Posted at 2024-05-25

cloudsqlでレプリケーションをつくってみました。

下記コード

main.tf
resource "google_sql_database_instance" "primary" {
  name             = "mysql-primary-instance-name"
  region           = "asia-northeast1"
  database_version = "MYSQL_8_0"
  settings {
    tier = "db-f1-micro"
    backup_configuration {
      enabled            = "true"
      binary_log_enabled = "true"
    }
  }
  
  deletion_protection = false
}

resource "google_sql_database_instance" "read_replica" {
  name                 = "mysql-replica-instance-name"
  master_instance_name = google_sql_database_instance.primary.name
  region               = "asia-northeast1"
  database_version     = "MYSQL_8_0"

  replica_configuration {
    failover_target = false
  }

  settings {
    tier              = "db-f1-micro"
    availability_type = "ZONAL"
    disk_size         = "10"
  }
  # 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
}

Terraformでユーザーを追加しようとするとエラーがでます。
ユーザーはGUIで登録するしかないです。

参考資料
https://zenn.dev/tomoyuki_kato/scraps/9d7e6b1633e921

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?