Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Container Apps Workload Profiled #1947 #1948

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
19 changes: 10 additions & 9 deletions container_apps.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ module "container_apps" {
source = "./modules/compute/container_app"
for_each = local.compute.container_apps

location = can(local.global_settings.regions[each.value.region]) ? local.global_settings.regions[each.value.region] : local.combined_objects_resource_groups[try(each.value.resource_group.lz_key, local.client_config.landingzone_key)][try(each.value.resource_group.key, each.value.resource_group_key)].location
resource_group = local.combined_objects_resource_groups[try(each.value.resource_group.lz_key, local.client_config.landingzone_key)][try(each.value.resource_group_key, each.value.resource_group.key)]
resource_group_name = can(each.value.resource_group.name) || can(each.value.resource_group_name) ? try(each.value.resource_group.name, each.value.resource_group_name) : local.combined_objects_resource_groups[try(each.value.resource_group.lz_key, local.client_config.landingzone_key)][try(each.value.resource_group_key, each.value.resource_group.key)].name
base_tags = local.global_settings.inherit_tags
container_app_environment_id = can(each.value.container_app_environment_id) ? each.value.container_app_environment_id : local.combined_objects_container_app_environments[try(each.value.lz_key, local.client_config.landingzone_key)][each.value.container_app_environment_key].id
client_config = local.client_config
combined_diagnostics = local.combined_diagnostics
diagnostic_profiles = try(each.value.diagnostic_profiles, {})
diagnostics = local.combined_diagnostics
location = can(local.global_settings.regions[each.value.region]) ? local.global_settings.regions[each.value.region] : local.combined_objects_resource_groups[try(each.value.resource_group.lz_key, local.client_config.landingzone_key)][try(each.value.resource_group.key, each.value.resource_group_key)].location
resource_group = local.combined_objects_resource_groups[try(each.value.resource_group.lz_key, local.client_config.landingzone_key)][try(each.value.resource_group_key, each.value.resource_group.key)]
resource_group_name = can(each.value.resource_group.name) || can(each.value.resource_group_name) ? try(each.value.resource_group.name, each.value.resource_group_name) : local.combined_objects_resource_groups[try(each.value.resource_group.lz_key, local.client_config.landingzone_key)][try(each.value.resource_group_key, each.value.resource_group.key)].name
base_tags = local.global_settings.inherit_tags
container_app_environment_id = can(each.value.container_app_environment_id) ? each.value.container_app_environment_id : local.combined_objects_container_app_environments[try(each.value.lz_key, local.client_config.landingzone_key)][each.value.container_app_environment_key].id
workload_profile_name = each.value.workload_profile_name
client_config = local.client_config
combined_diagnostics = local.combined_diagnostics
diagnostic_profiles = try(each.value.diagnostic_profiles, {})
diagnostics = local.combined_diagnostics
combined_resources = {
keyvaults = local.combined_objects_keyvaults
managed_identities = local.combined_objects_managed_identities
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ container_app_environments = {
}
internal_load_balancer_enabled = true
zone_redundancy_enabled = true
workload_profile {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
workload_profile {
workload_profile = {

Copy link
Author

@darrenhull darrenhull Jun 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry i didnt get a notification on this i will update it, i think i have a newer version on my fork.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated this now @arnaudlh is there any documentation on how to run the tests locally?

name = "caetest"
workload_profile_type = "D4"
minimum_count = 0
maximum_count = 1
}

tags = {
environment = "testing"
Expand Down
17 changes: 9 additions & 8 deletions modules/compute/container_app/container_app.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ resource "azurecaf_name" "ca" {
}

resource "azurerm_container_app" "ca" {
name = azurecaf_name.ca.result
resource_group_name = local.resource_group_name
container_app_environment_id = var.container_app_environment_id
revision_mode = var.settings.revision_mode
tags = merge(local.tags, try(var.settings.tags, null))

name = azurecaf_name.ca.result
resource_group_name = local.resource_group_name
container_app_environment_id = var.container_app_environment_id
workload_profile_name = var.workload_profile_name
revision_mode = var.settings.revision_mode
tags = merge(local.tags, try(var.settings.tags, null))

template {
dynamic "container" {
for_each = var.settings.template.container
Expand Down Expand Up @@ -230,9 +231,9 @@ resource "azurerm_container_app" "ca" {
for_each = try(ingress.value.traffic_weight, {})

content {
label = traffic_weight.value.label
label = var.settings.revision_mode == "Single" ? try(traffic_weight.value.label, null) : traffic_weight.value.label
latest_revision = traffic_weight.value.latest_revision
revision_suffix = traffic_weight.value.revision_suffix
revision_suffix = var.settings.revision_mode == "Single" ? try(traffic_weight.value.revision_suffix, null) : traffic_weight.value.revision_suffix
percentage = traffic_weight.value.percentage
}
}
Expand Down
4 changes: 4 additions & 0 deletions modules/compute/container_app/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ variable "resource_group" {
}
variable "settings" {}
variable "container_app_environment_id" {}
variable "workload_profile_name" {
description = "The name of the Workload Profile in the Container App Environment that this Container App should be placed in."
default = "Consumption"
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,13 @@ resource "azurerm_container_app_environment" "cae" {
internal_load_balancer_enabled = try(var.settings.internal_load_balancer_enabled, null)
zone_redundancy_enabled = try(var.settings.zone_redundancy_enabled, null)
tags = merge(local.tags, try(var.settings.tags, null))
dynamic "workload_profile" {
for_each = try(var.settings.workload_profile, null) != null ? [var.settings.workload_profile] : []
content {
name = workload_profile.value.name
workload_profile_type = workload_profile.value.workload_profile_type
minimum_count = workload_profile.value.minimum_count
maximum_count = workload_profile.value.maximum_count
}
}
}
Loading