fix bug caught by tests and yoris feedback
This commit is contained in:
@@ -48,7 +48,7 @@ resource "google_sql_database_instance" "master" {
|
||||
dynamic "authorized_networks" {
|
||||
for_each = var.authorized_networks
|
||||
content {
|
||||
name = authorized_networks.value.name
|
||||
name = lookup(authorized_networks.value, "name", null)
|
||||
value = authorized_networks.value.value
|
||||
}
|
||||
}
|
||||
@@ -117,10 +117,13 @@ resource "google_sql_database" "default" {
|
||||
resource "google_sql_user" "default" {
|
||||
depends_on = [google_sql_database.default]
|
||||
|
||||
name = var.master_user_name
|
||||
project = var.project
|
||||
name = var.master_user_name
|
||||
instance = google_sql_database_instance.master.name
|
||||
host = var.master_user_host
|
||||
# Postgres users don't have hosts, so the API will ignore this value which causes Terraform to attempt
|
||||
# to recreate the user each time.
|
||||
# See https://github.com/terraform-providers/terraform-provider-google/issues/1526 for more information.
|
||||
host = local.is_postgres ? null : var.master_user_host
|
||||
password = var.master_user_password
|
||||
}
|
||||
|
||||
@@ -295,6 +298,7 @@ resource "google_sql_database_instance" "read_replica" {
|
||||
# ------------------------------------------------------------------------------
|
||||
# CREATE A TEMPLATE FILE TO SIGNAL ALL RESOURCES HAVE BEEN CREATED
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
data "template_file" "complete" {
|
||||
depends_on = [
|
||||
google_sql_database_instance.master,
|
||||
|
||||
@@ -56,7 +56,7 @@ variable "activation_policy" {
|
||||
|
||||
variable "authorized_networks" {
|
||||
description = "A list of authorized CIDR-formatted IP address ranges that can connect to this DB. Only applies to public IP instances."
|
||||
type = list(any)
|
||||
type = list(map(string))
|
||||
default = []
|
||||
|
||||
# Example:
|
||||
@@ -173,7 +173,7 @@ variable "master_zone" {
|
||||
}
|
||||
|
||||
variable "master_user_host" {
|
||||
description = "The host part for the default user, i.e. 'master_user_name'@'master_user_host' IDENTIFIED BY 'master_user_password' "
|
||||
description = "The host part for the default user, i.e. 'master_user_name'@'master_user_host' IDENTIFIED BY 'master_user_password'. Don't set this field for Postgres instances."
|
||||
type = string
|
||||
default = "%"
|
||||
}
|
||||
@@ -249,6 +249,6 @@ variable "resource_timeout" {
|
||||
|
||||
variable "dependencies" {
|
||||
description = "Create a dependency between the resources in this module to the interpolated values in this list (and thus the source resources). In other words, the resources in this module will now depend on the resources backing the values in this list such that those resources need to be created before the resources in this module, and the resources in this module need to be destroyed before the resources in the list."
|
||||
type = list(any)
|
||||
type = list(string)
|
||||
default = []
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user