forked from Azure/terraform-azurerm-postgresql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
53 lines (46 loc) · 2.09 KB
/
main.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
provider "azurerm" {
version = ">=1.16.0"
}
resource "azurerm_postgresql_server" "server" {
name = "${var.server_name}"
location = "${var.location}"
resource_group_name = "${var.resource_group_name}"
sku {
name = "${var.sku_name}"
capacity = "${var.sku_capacity}"
tier = "${var.sku_tier}"
family = "${var.sku_family}"
}
storage_profile {
storage_mb = "${var.storage_mb}"
backup_retention_days = "${var.backup_retention_days}"
geo_redundant_backup = "${var.geo_redundant_backup}"
}
administrator_login = "${var.administrator_login}"
administrator_login_password = "${var.administrator_password}"
version = "${var.server_version}"
ssl_enforcement = "${var.ssl_enforcement}"
}
resource "azurerm_postgresql_database" "dbs" {
count = "${length(var.db_names)}"
name = "${var.db_names[count.index]}"
resource_group_name = "${var.resource_group_name}"
server_name = "${azurerm_postgresql_server.server.name}"
charset = "${var.db_charset}"
collation = "${var.db_collation}"
}
resource "azurerm_postgresql_firewall_rule" "firewall_rules" {
count = "${length(var.firewall_rules)}"
name = "${var.firewall_rule_prefix}${lookup(var.firewall_rules[count.index], "name", count.index)}"
resource_group_name = "${var.resource_group_name}"
server_name = "${azurerm_postgresql_server.server.name}"
start_ip_address = "${lookup(var.firewall_rules[count.index], "start_ip")}"
end_ip_address = "${lookup(var.firewall_rules[count.index], "end_ip")}"
}
resource "azurerm_postgresql_virtual_network_rule" "vnet_rules" {
count = "${length(var.vnet_rules)}"
name = "${var.vnet_rule_name_prefix}${lookup(var.vnet_rules[count.index], "name", count.index)}"
resource_group_name = "${var.resource_group_name}"
server_name = "${azurerm_postgresql_server.server.name}"
subnet_id = "${lookup(var.vnet_rules[count.index], "subnet_id")}"
}