Skip to content

Instantly share code, notes, and snippets.

@ellisio
Created April 25, 2019 18:51
Show Gist options
  • Save ellisio/fef3abd6a94400f2af528aa0ee330215 to your computer and use it in GitHub Desktop.
Save ellisio/fef3abd6a94400f2af528aa0ee330215 to your computer and use it in GitHub Desktop.
resource "google_sql_database_instance" "master" {
name = "${local.name}-master-1"
database_version = "${local.config["sql_version"]}"
settings {
tier = "${local.config["sql_tier"]}"
disk_type = "PD_SSD"
disk_size = "${local.config["sql_disk_size"]}"
disk_autoresize = true
activation_policy = "ALWAYS"
availability_type = "ZONAL"
replication_type = "SYNCHRONOUS"
ip_configuration {
require_ssl = false
private_network = "${google_compute_network.network.self_link}"
}
location_preference {
zone = "us-central1-c"
}
backup_configuration {
enabled = true
binary_log_enabled = true
start_time = "02:30" // 2:30 AM UTC
}
maintenance_window {
day = 7 // Sunday
hour = 23 // 11 PM UTC
update_track = "stable"
}
}
depends_on = [
"google_service_networking_connection.private_vpc"
]
}
resource "google_sql_database_instance" "failover" {
name = "${local.name}-failover"
database_version = "${local.config["sql_version"]}"
master_instance_name = "${google_sql_database_instance.master.name}"
replica_configuration {
failover_target = true
}
settings {
tier = "${local.config["sql_tier"]}"
disk_type = "PD_SSD"
disk_size = "${local.config["sql_disk_size"]}"
disk_autoresize = true
activation_policy = "ALWAYS"
availability_type = "ZONAL"
replication_type = "SYNCHRONOUS"
ip_configuration {
require_ssl = false
private_network = "${google_compute_network.network.self_link}"
}
location_preference {
zone = "us-central1-c"
}
maintenance_window {
day = 7
hour = 22
update_track = "stable"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment