-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcustom-container-apps.tf
107 lines (94 loc) · 3.52 KB
/
custom-container-apps.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
102
103
104
105
106
107
resource "azurerm_container_app" "custom_container_apps" {
for_each = local.custom_container_apps
name = each.key
container_app_environment_id = each.value.container_app_environment_id == "" ? local.container_app_environment.id : each.value.container_app_environment_id
resource_group_name = each.value.resource_group_name == "" ? local.resource_group.name : each.value.resource_group_name
revision_mode = each.value.revision_mode
dynamic "ingress" {
for_each = each.value.ingress != null ? [1] : []
content {
external_enabled = each.value.ingress.external_enabled
target_port = each.value.ingress.target_port
traffic_weight {
percentage = each.value.ingress.traffic_weight.percentage
latest_revision = true
}
}
}
dynamic "secret" {
for_each = { for i, v in concat(
local.enable_app_insights_integration ? [
{
name = "applicationinsights--connectionstring",
value = azurerm_application_insights.main[0].connection_string
},
{
name = "applicationinsights--instrumentationkey",
value = azurerm_application_insights.main[0].instrumentation_key
}
] : [],
each.value.secrets
) : v.name => v }
content {
name = secret.value["name"]
value = secret.value["value"]
}
}
dynamic "identity" {
for_each = each.value.identity
content {
type = identity.value.type
identity_ids = identity.value.identity_ids
}
}
dynamic "registry" {
for_each = each.value.registry != null ? [1] : []
content {
server = each.value.registry.server != "" ? each.value.registry.server : local.registry_server
username = each.value.registry.identity == "" ? each.value.registry.username != "" ? each.value.registry.username : local.registry_username : null
password_secret_name = each.value.registry.identity == "" ? each.value.registry.password_secret_name != "" ? each.value.registry.password_secret_name : "acr-password" : null
identity = each.value.registry.identity != "" ? each.value.registry.identity : null
}
}
template {
container {
name = each.key
image = each.value.image
cpu = each.value.cpu
memory = "${each.value.memory}Gi"
command = each.value.command
dynamic "liveness_probe" {
for_each = each.value.liveness_probes
content {
interval_seconds = liveness_probe.interval_seconds
transport = liveness_probe.transport
port = liveness_probe.port
path = liveness_probe.path
}
}
dynamic "env" {
for_each = { for i, v in concat(
local.enable_app_insights_integration ? [
{
"name" : "ApplicationInsights__ConnectionString",
"secretRef" : "applicationinsights--connectionstring"
},
{
"name" : "ApplicationInsights__InstrumentationKey",
"secretRef" : "applicationinsights--instrumentationkey"
}
] : [],
each.value.env,
) : v.name => v }
content {
name = env.value["name"]
secret_name = lookup(env.value, "secretRef", null)
value = lookup(env.value, "value", null)
}
}
}
min_replicas = each.value.min_replicas
max_replicas = each.value.max_replicas
}
tags = local.tags
}