/* 1. ResourceGroup */
resource "azurerm_resource_group" "freddy" {
name = "rg-freddy-dev-westeu"
location = "West Europe"
}
/* 2. Log Analytics Workspace */
resource "azurerm_log_analytics_workspace" "app_log_analytics" {
name = "log-freddy-dev-westeu"
location = azurerm_resource_group.freddy.location
resource_group_name = azurerm_resource_group.freddy.name
sku = "PerGB2018"
retention_in_days = 30
}
/* 3. Application Insights */
resource "azurerm_application_insights" "freddy_appinsights" {
name = "appi-freddy-dev-westeu"
location = azurerm_resource_group.freddy.location
resource_group_name = azurerm_resource_group.freddy.name
workspace_id = azurerm_log_analytics_workspace.app_log_analytics.id
application_type = "web"
}
/* 4. Container App Environment */
resource "azurerm_container_app_environment" "cae" {
name = "cae-freddy-dev-westeu"
location = azurerm_resource_group.freddy.location
resource_group_name = azurerm_resource_group.freddy.name
log_analytics_workspace_id = azurerm_log_analytics_workspace.app_log_analytics.id
}
resource "azurerm_container_app" "kitchen" {
name = "kitchen"
container_app_environment_id = azurerm_container_app_environment.cae.id
resource_group_name = azurerm_resource_group.freddy.name
revision_mode = "Single"
template {
container {
name = "kitchen"
image = "ghcr.io/remast/kitchen-aca:0.1.0"
cpu = 0.25
memory = "0.5Gi"
}
min_replicas = 0
max_replicas = 1
}
ingress {
target_port = 8070
traffic_weight {
latest_revision = true
percentage = 100
}
}
}
resource "azurerm_container_app" "order" {
name = "order"
container_app_environment_id = azurerm_container_app_environment.cae.id
resource_group_name = azurerm_resource_group.freddy.name
revision_mode = "Single"
template {
container {
name = "order"
image = "ghcr.io/remast/order-aca:0.1.0"
cpu = 0.5
memory = "1Gi"
env {
name = "DELIVERY_SERVICE_URL"
value = "http://delivery"
}
env {
name = "KITCHEN_SERVICE_URL"
value = "http://kitchen"
}
}
min_replicas = 0
max_replicas = 1
}
ingress {
target_port = 8060
traffic_weight {
latest_revision = true
percentage = 100
}
}
}
resource "azurerm_container_app" "shop-frontend" {
name = "shop-frontend"
container_app_environment_id = azurerm_container_app_environment.cae.id
resource_group_name = azurerm_resource_group.freddy.name
revision_mode = "Single"
template {
container {
name = "shop-frontend"
image = "ghcr.io/remast/shop-frontend-aca:0.2.0"
cpu = 0.25
memory = "0.5Gi"
}
min_replicas = 0
max_replicas = 1
}
ingress {
target_port = 4200
external_enabled = true
traffic_weight {
latest_revision = true
percentage = 100
}
}
}
output "shop_frontend_fqdn" {
value = azurerm_container_app.shop-frontend.latest_revision_fqdn
}
>_ terraform apply
azurerm_resource_group.freddy: Refreshing state...
azurerm_container_app_environment.cae: Refreshing state...
azurerm_container_app.delivery: Refreshing state...
azurerm_container_app.kitchen: Refreshing state...
azurerm_container_app.shop-frontend: Refreshing state...
azurerm_container_app.order: Refreshing state...
Terraform will perform the following actions:
# azurerm_container_app.order will be updated in-place
~ resource "azurerm_container_app" "order" {
~ template {
~ container {
~ memory = "0.5Gi" -> "1Gi"
}
}
}
Plan: 0 to add, 1 to change, 0 to destroy.
azurerm_container_app.order: Modifying...
azurerm_container_app.order: Modifications complete after 17s
Apply complete! Resources: 0 added, 1 changed, 0 destroyed.
Outputs:
shop_frontend_fqdn = "shop-frontend-03.victorious-3fb.westeurope.azurecontainerapps.io"
resource "azurerm_container_app" "kitchen" {
template {
container {
name = "kitchen"
image = "ghcr.io/remast/kitchen-aca:0.1.0"
cpu = 0.25
memory = "0.5Gi"
startup_probe {
interval_seconds = 5
failure_count_threshold = 3
port = 8070
path = "/health/readiness"
transport = "HTTP"
}
readiness_probe {
port = 8070
path = "/health/readiness"
transport = "HTTP"
}
liveness_probe {
port = 8070
path = "/health/liveness"
transport = "HTTP"
}
}
}
}
resource "azurerm_container_app" "order" {
name = "order"
secret {
name = "secret-api-key"
value = "***shush***"
}
template {
container {
name = "order"
image = "ghcr.io/remast/order-aca:0.1.0"
cpu = 0.5
memory = "1Gi"
env {
name = "DELIVERY_SERVICE_URL"
value = "http://delivery"
}
env {
name = "KITCHEN_SERVICE_URL"
value = "http://kitchen"
}
env {
name = "SECRET_API_KEY"
secret_name = "secret-api-key"
}
}
}
}
ContainerAppConsoleLogs_CL
ContainerAppSystemLogs_CL
Workload Profile | vCPU | Memory | |
---|---|---|---|
Consumption | 4 | 8 Gi | Standard |
Dedicated-D4 | 4 | 16 Gi | Allgemeine Nutzung |
Dedicated-E4 | 4 | 32Gi | Speicher optimiert |