remove gae inputs and only apply location_preference if vars are specified

This commit is contained in:
Rob Morgan
2020-11-13 11:15:41 +08:00
parent 4c4ac71eaf
commit 30b3d6bbdc
2 changed files with 20 additions and 30 deletions

View File

@@ -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

View File

@@ -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