Simplify Cloud SQL backup enablement logic
This commit is contained in:
@@ -20,13 +20,6 @@ locals {
|
||||
is_postgres = can(regex("^POSTGRES", var.database_version))
|
||||
has_replicas = length(var.replicas) > 0
|
||||
is_regional = var.availability_type == "REGIONAL" ? true : false
|
||||
# enable backup if the user asks for it or if the user is deploying
|
||||
# MySQL in HA configuration (regional or with specified replicas)
|
||||
enable_backup = (
|
||||
var.backup_configuration.enabled ||
|
||||
(local.is_mysql && local.has_replicas) ||
|
||||
(local.is_mysql && local.is_regional)
|
||||
)
|
||||
users = {
|
||||
for k, v in coalesce(var.users, {}) : k =>
|
||||
local.is_mysql
|
||||
@@ -109,7 +102,7 @@ resource "google_sql_database_instance" "primary" {
|
||||
}
|
||||
|
||||
dynamic "backup_configuration" {
|
||||
for_each = local.enable_backup ? { 1 = 1 } : {}
|
||||
for_each = var.backup_configuration.enabled ? { 1 = 1 } : {}
|
||||
content {
|
||||
enabled = true
|
||||
// enable binary log if the user asks for it or we have replicas (default in regional),
|
||||
|
||||
Reference in New Issue
Block a user