I have created four azure container apps through terraform azapi provider. Now I want to add the environment variables to the container apps. Keys and values are different for each containers What is the best way to do this?
esource “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.containerapp_environment.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
}
env = [
{
name = ??
value = ??
}
]
probes = [
{
“type”: “Liveness”
“httpGet”: {
“path”: each.value.probe_path != “” ? 0 : each.value.probe_path
“port”: each.value.probe_port != “” ? 0 : each.value.probe_path
“scheme”: each.value.probe_scheme != “” ? 0 : each.value.probe_path
}
}
]
}
]
scale = {
minReplicas = each.value.min_replicas
maxReplicas = each.value.max_replicas
rules = [
{}
]
}
}
}
})
depends_on = [
azapi_resource.containerapp_environment,
azurerm_log_analytics_workspace.loganalytics
]
}