-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.tf
53 lines (47 loc) · 1.75 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
locals {
common_tags = {
application = yamldecode(file("${path.module}/team-config.yml"))[var.product]["tags"]["application"]
businessArea = yamldecode(file("${path.module}/team-config.yml"))[var.product]["tags"]["businessArea"]
builtFrom = var.builtFrom
criticality = local.criticality[var.environment]
environment = [for x in keys(local.env_mapping) : x if contains(local.env_mapping[x], var.environment)][0]
}
additional_tags = {
autoShutdown = var.autoShutdown
startupMode = var.startupMode
}
# if var.expiresAfter set to "0000-00-00", set default date to date of creation + 14 days
expiresAfter = var.expiresAfter == "0000-00-00" ? formatdate("YYYY-MM-DD", timeadd(timestamp(), "336h")) : var.expiresAfter
all_tags = local.common_tags.environment == "sandbox" ? merge(local.common_tags, local.additional_tags, tomap({ "expiresAfter" = local.expiresAfter })) : merge(local.common_tags, local.additional_tags)
criticality = {
sbox = "Low"
aat = "High"
stg = "High"
prod = "High"
prod-int = "High"
ithc = "Medium"
test = "Medium"
perftest = "Medium"
demo = "Medium"
dev = "Low"
ptl = "High"
preview = "Low"
ldata = "High"
sandbox = "Low"
nle = "High"
nonprod = "Medium"
nonprodi = "Medium"
ptlsbox = "Low"
sbox-int = "Low"
mgmt = "High"
}
env_mapping = {
production = ["ptl", "prod", "prod-int", "mgmt", "management"]
development = ["dev", "preview"]
staging = ["ldata", "stg", "aat", "nle", "nonprod", "nonprodi"]
testing = ["test", "perftest"]
sandbox = ["sandbox", "sbox", "ptlsbox", "sbox-int"]
demo = ["demo"]
ithc = ["ithc"]
}
}