-
Notifications
You must be signed in to change notification settings - Fork 22
/
postgresql.tf
67 lines (55 loc) · 2.18 KB
/
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# resource "azurerm_resource_group" "postgres" {
# name = "rg-${var.region}-postgres"
# location = var.region
# }
resource "random_id" "rg_name" {
byte_length = 2
}
resource "azurerm_private_dns_zone" "postgres" {
name = "private.postgres.database.azure.com"
resource_group_name = azurerm_resource_group.rg.name
}
resource "azurerm_private_dns_zone_virtual_network_link" "postgres" {
name = azurerm_postgresql_flexible_server.postgres.name
private_dns_zone_name = azurerm_private_dns_zone.postgres.name
virtual_network_id = azurerm_virtual_network.vnet.id
resource_group_name = azurerm_resource_group.rg.name
}
resource "azurerm_postgresql_flexible_server" "postgres" {
name = "${var.psql-flexible}${random_id.rg_name.hex}"
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
version = "16"
delegated_subnet_id = azurerm_subnet.postgressubnet.id
private_dns_zone_id = azurerm_private_dns_zone.postgres.id
public_network_access_enabled = false
administrator_login = var.pgsql-user
administrator_password = "#QWEASDasdqwe"
zone = "1"
storage_mb = 32768
storage_tier = "P30"
sku_name = "B_Standard_B1ms"
# depends_on = [azurerm_private_dns_zone_virtual_network_link.postgres]
}
resource "azurerm_postgresql_flexible_server_database" "difypgsqldb" {
name = "difypgsqldb"
server_id = azurerm_postgresql_flexible_server.postgres.id
collation = "en_US.utf8"
charset = "utf8"
# prevent the possibility of accidental data loss
}
resource "azurerm_postgresql_flexible_server_database" "pgvector" {
name = "pgvector"
server_id = azurerm_postgresql_flexible_server.postgres.id
collation = "en_US.utf8"
charset = "utf8"
# prevent the possibility of accidental data loss
# lifecycle {
# prevent_destroy = true
# }
}
resource "azurerm_postgresql_flexible_server_configuration" "extension" {
name = "azure.extensions"
server_id = azurerm_postgresql_flexible_server.postgres.id
value = "vector,uuid-ossp"
}