This repository has been archived by the owner on Mar 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathr-postgresql.tf
42 lines (35 loc) · 1.77 KB
/
r-postgresql.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
resource "azurerm_postgresql_server" "postgresql_server" {
name = local.postgresql_server_name
location = var.location
resource_group_name = var.resource_group_name
sku_name = join("_", [lookup(local.tier_map, var.tier, "GeneralPurpose"), "Gen5", var.capacity])
storage_mb = var.storage_mb
backup_retention_days = var.backup_retention_days
geo_redundant_backup_enabled = var.geo_redundant_backup_enabled
auto_grow_enabled = var.auto_grow_enabled
administrator_login = var.administrator_login
administrator_login_password = var.administrator_password
version = var.postgresql_version
ssl_enforcement_enabled = var.force_ssl
ssl_minimal_tls_version_enforced = var.ssl_minimal_tls_version_enforced
public_network_access_enabled = var.public_network_access_enabled
tags = merge(
local.default_tags,
var.extra_tags,
)
}
resource "azurerm_postgresql_database" "postgresql_db" {
for_each = toset(var.databases_names)
name = var.use_caf_naming_for_databases ? data.azurecaf_name.postgresql_dbs[each.value].result : each.value
resource_group_name = var.resource_group_name
server_name = azurerm_postgresql_server.postgresql_server.name
charset = lookup(var.databases_charset, each.value, "UTF8")
collation = lookup(var.databases_collation, each.value, "en-US")
}
resource "azurerm_postgresql_configuration" "postgresql_config" {
for_each = merge(local.default_configurations, var.postgresql_configurations)
name = each.key
resource_group_name = var.resource_group_name
server_name = azurerm_postgresql_server.postgresql_server.name
value = each.value
}