-
Notifications
You must be signed in to change notification settings - Fork 23
/
aca.tf
56 lines (53 loc) · 1.57 KB
/
aca.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
resource "azapi_resource" "aca_env" {
type = "Microsoft.App/managedEnvironments@2022-03-01"
parent_id = azurerm_resource_group.rg.id
location = azurerm_resource_group.rg.location
name = "env-terraform"
tags = local.tags
body = jsonencode({
properties = {
appLogsConfiguration = {
destination = "log-analytics"
logAnalyticsConfiguration = {
customerId = azurerm_log_analytics_workspace.law.workspace_id
sharedKey = azurerm_log_analytics_workspace.law.primary_shared_key
}
}
}
})
}
resource "azapi_resource" "aca" {
for_each = { for ca in var.container_apps : ca.name => ca }
type = "Microsoft.App/containerApps@2022-03-01"
parent_id = azurerm_resource_group.rg.id
location = azurerm_resource_group.rg.location
name = each.value.name
body = jsonencode({
properties : {
managedEnvironmentId = azapi_resource.aca_env.id
configuration = {
ingress = {
external = each.value.ingress_enabled
targetPort = each.value.ingress_enabled ? each.value.containerPort : null
}
}
template = {
containers = [
{
name = "main"
image = "${each.value.image}:${each.value.tag}"
resources = {
cpu = each.value.cpu_requests
memory = each.value.mem_requests
}
}
]
scale = {
minReplicas = each.value.min_replicas
maxReplicas = each.value.max_replicas
}
}
}
})
tags = local.tags
}