I would like to create a module that deploys a postgres flexible server where a var can be set to make the setup HA or not. But i cannot get this to work. I created the following code:
resource "azurerm_postgresql_flexible_server" "default" {
name = var.databaseserver_name
resource_group_name = var.resource_group_name
location = var.location
version = var.postgres_version
delegated_subnet_id = azurerm_subnet.default.id
private_dns_zone_id = var.private_dns_zone_id
administrator_login = var.administrator_login
administrator_password = var.administrator_password
zone = var.availibility_zone
sku_name = var.sku_name
backup_retention_days = var.backup_retention
geo_redundant_backup_enabled = var.geo_redundant_backup
storage_mb = var.storage_mb
dynamic "high_availability" {
for_each = var.high_availability == "enabled" ? [] : [1]
content {
mode = "ZoneRedundant"
}
}
}
but this will create a HA setup even if var.high_availability is not set to enabled.
Is there a way to make this work ?