Skip to content

Commit

Permalink
fix: bug with workload profiles (#118)
Browse files Browse the repository at this point in the history
* fix: bug with workload profiles
* chore: remove unused local
* feat: use sets to prevent ordering issues
  • Loading branch information
matt-FFFFFF authored Jan 29, 2025
1 parent 788fbea commit 9d77ff0
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ Default: `true`

### <a name="input_infrastructure_resource_group_name"></a> [infrastructure\_resource\_group\_name](#input\_infrastructure\_resource\_group\_name)

Description: Name of the platform-managed resource group created for the Managed Environment to host infrastructure resources.
Description: Name of the platform-managed resource group created for the Managed Environment to host infrastructure resources.
If a subnet ID is provided, this resource group will be created in the same subscription as the subnet.
If not specified, then one will be generated automatically, in the form `ME_<app_managed_environment_name>_<resource_group>_<location>`.

Expand Down Expand Up @@ -357,7 +357,7 @@ Default: `null`

Description:
This lists the workload profiles that will be configured for the Managed Environment.
This is in addition to the default Consumpion Plan workload profile.
This is in addition to the default Consumption Plan workload profile.

- `maximum_count` - (Optional) The maximum number of instances of workload profile that can be deployed in the Container App Environment.
- `minimum_count` - (Optional) The minimum number of instances of workload profile that can be deployed in the Container App Environment.
Expand Down
23 changes: 18 additions & 5 deletions locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,22 @@ locals {
id = sv.resource_id
}
}
# this is used to mimic the behaviour of the azurerm provider
workload_profile_consumption_enabled = contains([
for wp in var.workload_profile :
wp.name == "Consumption" && wp.workload_profile_type == "Consumption"
], true)
workload_profiles = toset(concat(
[
for wp in var.workload_profile : {
name = wp.name
workloadProfileType = wp.workload_profile_type
minimumCount = wp.minimum_count
maximumCount = wp.maximum_count
}
],
[
{
name = "Consumption"
workloadProfileType = "Consumption"
minimumCount = null
maximumCount = null
}
],
))
}
17 changes: 2 additions & 15 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,8 @@ resource "azapi_resource" "this_environment" {
"internal" = var.internal_load_balancer_enabled
"infrastructureSubnetId" = var.infrastructure_subnet_id
} : null
workloadProfiles = local.workload_profile_consumption_enabled ? setunion([
{
name = "Consumption"
workloadProfileType = "Consumption"
}],
[for wp in var.workload_profile :
{
name = wp.name
workloadProfileType = wp.workload_profile_type
minimumCount = wp.minimum_count
maximumCount = wp.maximum_count
} if wp.workload_profile_type != "Consumption"
]
) : null
zoneRedundant = var.zone_redundancy_enabled
workloadProfiles = local.workload_profiles
zoneRedundant = var.zone_redundancy_enabled
},
# Only include the infrastructureResourceGroup property if it is set
#
Expand Down
4 changes: 2 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ variable "infrastructure_resource_group_name" {
type = string
default = null
description = <<DESCRIPTION
Name of the platform-managed resource group created for the Managed Environment to host infrastructure resources.
Name of the platform-managed resource group created for the Managed Environment to host infrastructure resources.
If a subnet ID is provided, this resource group will be created in the same subscription as the subnet.
If not specified, then one will be generated automatically, in the form ``ME_<app_managed_environment_name>_<resource_group>_<location>``.
DESCRIPTION
Expand Down Expand Up @@ -222,7 +222,7 @@ variable "workload_profile" {
description = <<DESCRIPTION
This lists the workload profiles that will be configured for the Managed Environment.
This is in addition to the default Consumpion Plan workload profile.
This is in addition to the default Consumption Plan workload profile.
- `maximum_count` - (Optional) The maximum number of instances of workload profile that can be deployed in the Container App Environment.
- `minimum_count` - (Optional) The minimum number of instances of workload profile that can be deployed in the Container App Environment.
Expand Down

0 comments on commit 9d77ff0

Please sign in to comment.