diff --git a/postgres/README.md b/postgres/README.md index cc3e08d..d0c2a57 100644 --- a/postgres/README.md +++ b/postgres/README.md @@ -36,6 +36,7 @@ No modules. | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| +| [availability](#input\_availability) | Type of availability (normal=ZONAL, HA=REGIONAL) | `string` | `"ZONAL"` | no | | [backup](#input\_backup) | Switch to enable backups | `bool` | `true` | no | | [db-size](#input\_db-size) | DB size/type | `string` | `"db-f1-micro"` | no | | [db-version](#input\_db-version) | DB type and version (e.g. POSTGRES\_14) | `string` | `"POSTGRES_14"` | no | diff --git a/postgres/main.tf b/postgres/main.tf index 8095a08..9e1a718 100644 --- a/postgres/main.tf +++ b/postgres/main.tf @@ -27,6 +27,7 @@ resource "google_sql_database_instance" "this" { point_in_time_recovery_enabled = true } } + availability_type = var.availability } depends_on = [google_service_networking_connection.this] } diff --git a/postgres/variables.tf b/postgres/variables.tf index 94ba803..29415cb 100644 --- a/postgres/variables.tf +++ b/postgres/variables.tf @@ -1,3 +1,13 @@ +variable "availability" { + default = "ZONAL" + description = "Type of availability (normal=ZONAL, HA=REGIONAL)" + type = string + validation { + condition = contains(["ZONAL", "REGIONAL"], var.availability) + error_message = "It has to be 'ZONAL' or 'REGIONAL'" + } +} + variable "backup" { default = true description = "Switch to enable backups"