Skip to content

Commit

Permalink
feat(infra): enable HA for postgresql
Browse files Browse the repository at this point in the history
  • Loading branch information
arealmaas committed Feb 25, 2025
1 parent 691492a commit b9211e0
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .azure/infrastructure/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ param postgresConfiguration {
storage: PostgresStorageConfig
enableIndexTuning: bool
enableQueryPerformanceInsight: bool
enableHighAvailability: bool
}

import { Sku as ServiceBusSku } from '../modules/serviceBus/main.bicep'
Expand Down Expand Up @@ -214,6 +215,7 @@ module postgresql '../modules/postgreSql/create.bicep' = {
enableQueryPerformanceInsight: postgresConfiguration.enableQueryPerformanceInsight
subnetId: vnet.outputs.postgresqlSubnetId
vnetId: vnet.outputs.virtualNetworkId
enableHighAvailability: postgresConfiguration.enableHighAvailability
tags: tags
}
}
Expand Down
1 change: 1 addition & 0 deletions .azure/infrastructure/prod.bicepparam
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ param postgresConfiguration = {
}
enableIndexTuning: false
enableQueryPerformanceInsight: false
highAvailability: true
}

param redisSku = {
Expand Down
1 change: 1 addition & 0 deletions .azure/infrastructure/staging.bicepparam
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ param postgresConfiguration = {
}
enableIndexTuning: true
enableQueryPerformanceInsight: true
highAvailability: true
}

param redisSku = {
Expand Down
1 change: 1 addition & 0 deletions .azure/infrastructure/test.bicepparam
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ param postgresConfiguration = {
}
enableIndexTuning: false
enableQueryPerformanceInsight: true
highAvailability: false
}

param redisSku = {
Expand Down
1 change: 1 addition & 0 deletions .azure/infrastructure/yt01.bicepparam
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ param postgresConfiguration = {
}
enableIndexTuning: true
enableQueryPerformanceInsight: true
highAvailability: false
}

param redisSku = {
Expand Down
9 changes: 9 additions & 0 deletions .azure/modules/postgreSql/create.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ param enableIndexTuning bool
@description('The name of the Application Insights workspace')
param appInsightWorkspaceName string

@description('Enable high availability')
param enableHighAvailability bool

@description('The Key Vault to store the PostgreSQL administrator login password')
@secure()
param srcKeyVault object
Expand Down Expand Up @@ -86,6 +89,11 @@ module privateDnsZone '../privateDnsZone/main.bicep' = {
}
}

var highAvailabilityConfig = enableHighAvailability ? {
mode: 'ZoneRedundant'
standbyAvailabilityZone: '2'
} : null

resource postgres 'Microsoft.DBforPostgreSQL/flexibleServers@2024-08-01' = {
name: postgresServerName
location: location
Expand All @@ -106,6 +114,7 @@ resource postgres 'Microsoft.DBforPostgreSQL/flexibleServers@2024-08-01' = {
delegatedSubnetResourceId: subnetId
privateDnsZoneArmResourceId: privateDnsZone.outputs.id
}
highAvailability: highAvailabilityConfig
}
sku: sku
resource database 'databases' = {
Expand Down

0 comments on commit b9211e0

Please sign in to comment.