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

feat(infra): enable HA and increase retention for postgresql #1955

Merged
merged 4 commits into from
Feb 26, 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
4 changes: 4 additions & 0 deletions .azure/infrastructure/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ param postgresConfiguration {
storage: PostgresStorageConfig
enableIndexTuning: bool
enableQueryPerformanceInsight: bool
enableHighAvailability: bool
backupRetentionDays: int
}

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

param redisSku = {
Expand Down
2 changes: 2 additions & 0 deletions .azure/infrastructure/staging.bicepparam
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ param postgresConfiguration = {
}
enableIndexTuning: true
enableQueryPerformanceInsight: true
enableHighAvailability: false
backupRetentionDays: 7
}

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

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

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

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

@description('The number of days to retain backups. If not specified, the default value of 7 days will be used.')
@minValue(7)
@maxValue(35)
param backupRetentionDays int

@description('The Key Vault to store the PostgreSQL administrator login password')
@secure()
param srcKeyVault object
Expand Down Expand Up @@ -86,6 +94,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 @@ -98,6 +111,10 @@ resource postgres 'Microsoft.DBforPostgreSQL/flexibleServers@2024-08-01' = {
autoGrow: storage.autoGrow
type: storage.type
}
backup: {
backupRetentionDays: backupRetentionDays
geoRedundantBackup: 'Disabled'
}
dataEncryption: {
type: 'SystemManaged'
}
Expand All @@ -106,6 +123,7 @@ resource postgres 'Microsoft.DBforPostgreSQL/flexibleServers@2024-08-01' = {
delegatedSubnetResourceId: subnetId
privateDnsZoneArmResourceId: privateDnsZone.outputs.id
}
highAvailability: highAvailabilityConfig
}
sku: sku
resource database 'databases' = {
Expand Down
Loading