Skip to content

Commit 18fb36b

Browse files
committed
Adding postgres database configuration
1 parent 976d02a commit 18fb36b

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

examples/PostgreSQL_Server/main.tf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ module "postgresql-db" {
3434
ssl_enforcement_enabled = true
3535
ssl_minimal_tls_version_enforced = "TLS1_2"
3636
}
37-
/*
38-
# MySQL Server Parameters
39-
# For more information: https://docs.microsoft.com/en-us/azure/mysql/concepts-server-parameters
40-
mysql_configuration = {
41-
interactive_timeout = "600"
42-
}
4337

38+
# PostgreSQL Server Parameters
39+
# For more information: https://bit.ly/3dbYTtB
40+
postgresql_configuration = {
41+
backslash_quote = "on"
42+
}
43+
/*
4444
# Use Virtual Network service endpoints and rules for Azure Database for MySQL
4545
subnet_id = var.subnet_id
4646

main.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,14 @@ resource "azurerm_postgresql_database" "main" {
128128
collation = var.postgresql_server_settings.collation
129129
}
130130

131+
#------------------------------------------------------------
132+
# Adding PostgreSQL Server Parameters - Default is "false"
133+
#------------------------------------------------------------
134+
resource "azurerm_postgresql_configuration" "main" {
135+
for_each = var.postgresql_configuration != null ? { for k, v in var.postgresql_configuration : k => v if v != null } : {}
136+
name = format("%s", each.key)
137+
resource_group_name = local.resource_group_name
138+
server_name = azurerm_postgresql_server.main.name
139+
value = each.value
140+
}
141+

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ variable "log_retention_days" {
109109
default = "30"
110110
}
111111

112+
variable "postgresql_configuration" {
113+
description = "Sets a PostgreSQL Configuration value on a PostgreSQL Server"
114+
type = map(string)
115+
default = {}
116+
}
117+
112118
variable "tags" {
113119
description = "A map of tags to add to all resources"
114120
type = map(string)

0 commit comments

Comments
 (0)