diff --git a/database.tf b/database.tf index d30ba34..f4ae841 100644 --- a/database.tf +++ b/database.tf @@ -15,8 +15,16 @@ resource "google_sql_database_instance" "serverpod" { } ip_configuration { - ipv4_enabled = true - private_network = google_compute_network.serverpod.id + ipv4_enabled = true + private_network = google_compute_network.serverpod.id + + dynamic "authorized_networks" { + for_each = var.authorized_networks == null ? [] : [var.authorized_networks] + content { + name = var.authorized_networks.name + value = var.authorized_networks.value + } + } } } diff --git a/variables.tf b/variables.tf index 1853c05..a893089 100644 --- a/variables.tf +++ b/variables.tf @@ -26,6 +26,15 @@ variable "top_domain" { type = string } +variable "authorized_networks" { + description = "The networks authorized to connect to the database from outside the Serverpod infrastructure." + type = object({ + name = string + value = string + }) + default = null +} + variable "autoscaling_min_size" { description = "The minimum number of instances to run in the autoscaling group. Defaults to 1." default = 1