generated from tothenew/terraform-aws-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
_locals.tf
68 lines (59 loc) · 2.11 KB
/
_locals.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
locals {
vcore_tiers = ["GeneralPurpose", "BusinessCritical"]
elastic_pool_vcore_family = try(var.elastic_pool_sku.family, "Gen5")
elastic_pool_vcore_sku_name = var.elastic_pool_sku != null ? format("%s_%s", var.elastic_pool_sku.tier == "GeneralPurpose" ? "GP" : "BC", local.elastic_pool_vcore_family) : null
elastic_pool_dtu_sku_name = var.elastic_pool_sku != null ? format("%sPool", var.elastic_pool_sku.tier) : null
elastic_pool_sku = var.elastic_pool_sku != null ? {
name = contains(local.vcore_tiers, var.elastic_pool_sku.tier) ? local.elastic_pool_vcore_sku_name : local.elastic_pool_dtu_sku_name
capacity = var.elastic_pool_sku.capacity
tier = var.elastic_pool_sku.tier
family = contains(local.vcore_tiers, var.elastic_pool_sku.tier) ? local.elastic_pool_vcore_family : null
} : null
allowed_subnets = [
for id in var.allowed_subnets_ids : {
name = split("/", id)[10]
subnet_id = id
}
]
databases_users = var.create_databases_users ? [
for db in var.databases : {
username = format("%s_user", replace(db.name, "-", "_"))
database = db.name
roles = ["db_owner"]
}
] : []
standard_allowed_create_mode = {
"a" = "Default"
"b" = "Copy"
"c" = "Secondary"
"d" = "PointInTimeRestore"
"e" = "Restore"
"f" = "Recovery"
"g" = "RestoreExternalBackup"
"h" = "RestoreExternalBackup"
"i" = "RestoreLongTermRetentionBackup"
"j" = "OnlineSecondary"
}
datawarehouse_allowed_create_mode = {
"a" = "Default"
"b" = "PointInTimeRestore"
"c" = "Restore"
"d" = "Recovery"
"e" = "RestoreExternalBackup"
"f" = "RestoreExternalBackup"
"g" = "OnlineSecondary"
}
}
locals {
# Naming locals/constants
name_prefix = lower(var.name_prefix)
name_suffix = lower(var.name_suffix)
server_name = coalesce(var.server_custom_name, data.azurecaf_name.sql.result)
elastic_pool_name = coalesce(var.elastic_pool_custom_name, data.azurecaf_name.sql_pool.result)
}
locals {
default_tags = var.default_tags_enabled ? {
env = var.environment
stack = var.stack
} : {}
}