Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Updated Postgres module with new High Availability enable method #305

Merged
merged 2 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/purple-sheep-compete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"azure_postgres_server": patch
---

Removed HA if WEU as Default, added override variable for HA
1 change: 1 addition & 0 deletions infra/modules/azure_postgres_server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
| <a name="input_diagnostic_settings"></a> [diagnostic\_settings](#input\_diagnostic\_settings) | Define if diagnostic settings should be enabled.<br/>if it is:<br/>Specifies the ID of a Log Analytics Workspace where Diagnostics Data should be sent and <br/>the ID of the Storage Account where logs should be sent. (Changing this forces a new resource to be created) | <pre>object({<br/> enabled = bool<br/> log_analytics_workspace_id = string<br/> diagnostic_setting_destination_storage_id = string<br/> })</pre> | <pre>{<br/> "diagnostic_setting_destination_storage_id": null,<br/> "enabled": false,<br/> "log_analytics_workspace_id": null<br/>}</pre> | no |
| <a name="input_enable_lock"></a> [enable\_lock](#input\_enable\_lock) | Define if lock should be enabled. | `bool` | `true` | no |
| <a name="input_environment"></a> [environment](#input\_environment) | Values which are used to generate resource names and location short names. They are all mandatory except for domain, which should not be used only in the case of a resource used by multiple domains. | <pre>object({<br/> prefix = string<br/> env_short = string<br/> location = string<br/> domain = optional(string)<br/> app_name = string<br/> instance_number = string<br/> })</pre> | n/a | yes |
| <a name="input_high_availability_override"></a> [high\_availability\_override](#input\_high\_availability\_override) | Override if high availability should be enabled. | `bool` | `false` | no |
| <a name="input_pgbouncer_enabled"></a> [pgbouncer\_enabled](#input\_pgbouncer\_enabled) | Is PgBouncer enabled into configurations? | `bool` | `true` | no |
| <a name="input_private_dns_zone_resource_group_name"></a> [private\_dns\_zone\_resource\_group\_name](#input\_private\_dns\_zone\_resource\_group\_name) | Resource group of the private DNS zone | `string` | n/a | yes |
| <a name="input_replica_zone"></a> [replica\_zone](#input\_replica\_zone) | (Optional) Specifies the Availability Zone in which the Replica PostgreSQL Flexible Server should be located. | `string` | `null` | no |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ resource "azurerm_resource_group" "example" {
data "azurerm_subnet" "pep" {
name = "${local.project}-pep-snet-01"
virtual_network_name = "${local.project}-common-vnet-01"
resource_group_name = "${local.project}-common-rg-01"
resource_group_name = "${local.project}-network-rg-01"
}

# tflint-ignore: terraform_required_providers
Expand Down Expand Up @@ -71,9 +71,9 @@ module "azure_postgres" {

environment = local.environment
resource_group_name = azurerm_resource_group.example.name
private_dns_zone_resource_group_name = azurerm_resource_group.example.name
private_dns_zone_resource_group_name = "${local.project}-network-rg-01"

tier = "l"
tier = "s"

administrator_credentials = {
name = azurerm_key_vault_secret.postgres_username.value
Expand Down
3 changes: 2 additions & 1 deletion infra/modules/azure_postgres_server/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ locals {

# Backup
# Geo redundant backup is not available in Italy North
# ZoneRedundant HA is not available in West Europe
geo_redundant_backup_enabled = (var.tier == "m" || var.tier == "l") && lower(var.environment.location) != "italynorth"
high_availability_enabled = var.tier == "m" || var.tier == "l"
high_availability_enabled = var.high_availability_override ? true : (var.tier == "m" || var.tier == "l") && lower(var.environment.location) != "westeurope"
auto_grow_enabled = var.tier == "m" || var.tier == "l"

# Monitoring
Expand Down
6 changes: 6 additions & 0 deletions infra/modules/azure_postgres_server/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -267,4 +267,10 @@ variable "enable_lock" {
type = bool
default = true
description = "Define if lock should be enabled."
}

variable "high_availability_override" {
type = bool
default = false
description = "Override if high availability should be enabled."
}
Loading