/
main.tf
59 lines (50 loc) · 1.88 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
54
55
56
57
58
59
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "example" {
name = "${var.prefix}-resources"
location = var.location
}
resource "azurerm_mssql_server" "example" {
name = "${var.prefix}-server-primary"
resource_group_name = azurerm_resource_group.example.name
location = var.location
version = "12.0"
administrator_login = "mradministrator"
administrator_login_password = "thisIsDog11"
}
resource "azurerm_mssql_server" "secondary" {
name = "${var.prefix}-server-secondary"
resource_group_name = azurerm_resource_group.example.name
location = var.location_alt
version = "12.0"
administrator_login = "mradministrator"
administrator_login_password = "thisIsDog11"
}
resource "azurerm_mssql_database" "example" {
name = "${var.prefix}-db-primary"
server_id = azurerm_mssql_server.example.id
collation = "SQL_AltDiction_CP850_CI_AI"
license_type = "BasePrice"
sku_name = "GP_Gen5_2"
}
resource "azurerm_mssql_database" "secondary" {
name = "${var.prefix}-db-secondary"
server_id = azurerm_mssql_server.secondary.id
create_mode = "Secondary"
creation_source_database_id = azurerm_mssql_database.example.id
}
resource "azurerm_sql_failover_group" "example" {
name = "${var.prefix}-failover-group"
resource_group_name = azurerm_resource_group.example.name
server_name = azurerm_mssql_server.example.name
databases = [azurerm_mssql_database.example.id]
partner_servers {
id = azurerm_mssql_server.secondary.id
}
read_write_endpoint_failover_policy {
mode = "Automatic"
grace_minutes = 60
}
depends_on = [azurerm_mssql_database.secondary]
}