generated from Azure/terraform-verified-module
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathresources.sqlsvr.tf
101 lines (78 loc) · 3.46 KB
/
resources.sqlsvr.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
resource "random_password" "main" {
length = var.random_password_length
min_upper = 4
min_lower = 2
min_numeric = 4
special = false
keepers = {
administrator_login_password = local.primary_server_name
}
}
resource "azurerm_mssql_server" "primary_sql" {
name = local.primary_server_name
resource_group_name = local.resource_group_name
location = local.location
version = var.server_version
connection_policy = var.connection_policy
minimum_tls_version = var.tls_minimum_version
public_network_access_enabled = var.public_network_access_enabled
outbound_network_restriction_enabled = var.outbound_network_restriction_enabled
administrator_login = var.administrator_login == null ? "sqladmin" : var.administrator_login
administrator_login_password = var.administrator_password == null ? random_password.main.result : var.administrator_password
dynamic "identity" {
for_each = var.enable_identity == true ? [1] : [0]
content {
type = "SystemAssigned"
}
}
tags = merge(local.default_tags, var.add_tags, var.server_add_tags)
}
#-------------------------------------------------------------
# SQL servers - Secondary server is depends_on Failover Group
#-------------------------------------------------------------
resource "azurerm_mssql_server" "secondary_sql" {
count = var.enable_failover_group ? 1 : 0
name = local.secondary_server_name
resource_group_name = local.resource_group_name
location = local.location
version = var.server_version
connection_policy = var.connection_policy
minimum_tls_version = var.tls_minimum_version
public_network_access_enabled = var.public_network_access_enabled
outbound_network_restriction_enabled = var.outbound_network_restriction_enabled
administrator_login = var.administrator_login == null ? "sqladmin" : var.administrator_login
administrator_login_password = var.administrator_password == null ? random_password.main.result : var.administrator_password
dynamic "identity" {
for_each = var.enable_identity == true ? [1] : [0]
content {
type = "SystemAssigned"
}
}
tags = merge(local.default_tags, var.add_tags, var.server_add_tags)
}
#-------------------------------------------------------------
# SQL servers - elasticpool
#-------------------------------------------------------------
resource "azurerm_mssql_elasticpool" "elastic_pool" {
count = var.enable_elastic_pool ? 1 : 0
name = local.elastic_pool_name
location = local.location
resource_group_name = local.resource_group_name
license_type = var.elastic_pool_license_type
server_name = azurerm_mssql_server.primary_sql.name
per_database_settings {
max_capacity = coalesce(var.elastic_pool_databases_max_capacity, var.elastic_pool_sku.capacity)
min_capacity = var.elastic_pool_databases_min_capacity
}
max_size_gb = var.elastic_pool_max_size
zone_redundant = var.elastic_pool_zone_redundant
sku {
capacity = local.elastic_pool_sku.capacity
name = local.elastic_pool_sku.name
tier = local.elastic_pool_sku.tier
family = local.elastic_pool_sku.family
}
tags = merge(local.default_tags, var.add_tags, var.elastic_pool_add_tags)
}