From 30b3d6bbdc3caa28924b4364acb2730a1bde0c8a Mon Sep 17 00:00:00 2001 From: Rob Morgan Date: Fri, 13 Nov 2020 11:15:41 +0800 Subject: [PATCH] remove gae inputs and only apply location_preference if vars are specified --- modules/cloud-sql/main.tf | 38 ++++++++++++++++++---------------- modules/cloud-sql/variables.tf | 12 ----------- 2 files changed, 20 insertions(+), 30 deletions(-) diff --git a/modules/cloud-sql/main.tf b/modules/cloud-sql/main.tf index 97a7e0f..0336c17 100644 --- a/modules/cloud-sql/main.tf +++ b/modules/cloud-sql/main.tf @@ -46,10 +46,9 @@ resource "google_sql_database_instance" "master" { database_version = var.engine settings { - tier = var.machine_type - activation_policy = var.activation_policy - authorized_gae_applications = var.authorized_gae_applications - disk_autoresize = var.disk_autoresize + tier = var.machine_type + activation_policy = var.activation_policy + disk_autoresize = var.disk_autoresize ip_configuration { dynamic "authorized_networks" { @@ -65,9 +64,12 @@ resource "google_sql_database_instance" "master" { require_ssl = var.require_ssl } - location_preference { - follow_gae_application = var.follow_gae_application - zone = var.master_zone + dynamic "location_preference" { + for_each = var.master_zone == null ? [] : list(var.master_zone) + + content { + zone = location_preference.value + } } backup_configuration { @@ -178,9 +180,8 @@ resource "google_sql_database_instance" "failover_replica" { settings { crash_safe_replication = true - tier = var.machine_type - authorized_gae_applications = var.authorized_gae_applications - disk_autoresize = var.disk_autoresize + tier = var.machine_type + disk_autoresize = var.disk_autoresize ip_configuration { dynamic "authorized_networks" { @@ -196,9 +197,12 @@ resource "google_sql_database_instance" "failover_replica" { require_ssl = var.require_ssl } - location_preference { - follow_gae_application = var.follow_gae_application - zone = var.mysql_failover_replica_zone + dynamic "location_preference" { + for_each = var.mysql_failover_replica_zone == null ? [] : list(var.mysql_failover_replica_zone) + + content { + zone = location_preference.value + } } disk_size = var.disk_size @@ -254,9 +258,8 @@ resource "google_sql_database_instance" "read_replica" { } settings { - tier = var.machine_type - authorized_gae_applications = var.authorized_gae_applications - disk_autoresize = var.disk_autoresize + tier = var.machine_type + disk_autoresize = var.disk_autoresize ip_configuration { dynamic "authorized_networks" { @@ -273,8 +276,7 @@ resource "google_sql_database_instance" "read_replica" { } location_preference { - follow_gae_application = var.follow_gae_application - zone = element(var.read_replica_zones, count.index) + zone = element(var.read_replica_zones, count.index) } disk_size = var.disk_size diff --git a/modules/cloud-sql/variables.tf b/modules/cloud-sql/variables.tf index 8fb5719..5c0f15b 100644 --- a/modules/cloud-sql/variables.tf +++ b/modules/cloud-sql/variables.tf @@ -69,12 +69,6 @@ variable "authorized_networks" { # ] } -variable "authorized_gae_applications" { - description = "A list of Google App Engine (GAE) project names that are allowed to access this instance." - type = list(string) - default = [] -} - variable "backup_enabled" { description = "Set to false if you want to disable backup." type = bool @@ -160,12 +154,6 @@ variable "disk_type" { default = "PD_SSD" } -variable "follow_gae_application" { - description = "A GAE application whose zone to remain in. Must be in the same region as this instance." - type = string - default = null -} - variable "master_zone" { description = "Preferred zone for the master instance (e.g. 'us-central1-a'). 'region'. If null, Google will auto-assign a zone." type = string