Open kawahara-titan opened 7 months ago
I can confirm we are facing the same issue up to the latest provider version. (3.96.0 as of writing this)
We could work around by defining 2 resource blocks and conditionally create one of them:
# Default Container Apps Environment
resource "azurerm_container_app_environment" "caen" {
# for_each = var.infrastructure_subnet_id == null ? toset(["default"]) : toset([])
count = var.infrastructure_subnet_id == null ? 1 : 0
name = local.caen_name
resource_group_name = var.resource_group_name
location = var.conventions.region
tags = local.tags
dapr_application_insights_connection_string = var.dapr_application_insights_connection_string
log_analytics_workspace_id = var.caen_log_analytics_workspace_id
dynamic "workload_profile" {
for_each = var.workload_profile == null ? [] : [1]
content {
name = var.workload_profile.workload_profile_name
workload_profile_type = var.workload_profile.workload_profile_type
maximum_count = var.workload_profile.maximum_count
minimum_count = var.workload_profile.minimum_count
}
}
infrastructure_resource_group_name = var.workload_profile != null ? "${var.resource_group_name}-infra" : null
}
AND
# VNET Integrated Container Apps Environment
resource "azurerm_container_app_environment" "caen_vnet" {
# for_each = var.infrastructure_subnet_id != null ? toset(["vnet_integrated"]) : toset([])
count = var.infrastructure_subnet_id != null ? 1 : 0
name = local.caen_name
resource_group_name = var.resource_group_name
location = var.conventions.region
tags = local.tags
dapr_application_insights_connection_string = var.dapr_application_insights_connection_string
log_analytics_workspace_id = var.caen_log_analytics_workspace_id
dynamic "workload_profile" {
for_each = var.workload_profile == null ? [] : [1]
content {
name = var.workload_profile.workload_profile_name
workload_profile_type = var.workload_profile.workload_profile_type
maximum_count = var.workload_profile.maximum_count
minimum_count = var.workload_profile.minimum_count
}
}
infrastructure_resource_group_name = var.workload_profile != null ? "${var.resource_group_name}-infra" : null
infrastructure_subnet_id = var.infrastructure_subnet_id
internal_load_balancer_enabled = var.internal_load_balancer_enabled
zone_redundancy_enabled = var.zone_redundancy_enabled
}
Is there an existing issue for this?
Community Note
Terraform Version
1.7.1
AzureRM Provider Version
3.96
Affected Resource(s)/Data Source(s)
azurerm_container_app_environment
Terraform Configuration Files
Debug Output/Panic Output
Expected Behaviour
If both internal_load_balancer_enabled and infrastructure_subnet_id are set to true, it works as expected. When set to false, I would expect the plan operation to not require infrastructure_subnet_id and therefore accept a null value.
Actual Behaviour
Receive the following error:
"internal_load_balancer_enabled": all of
infrastructure_subnet_id,internal_load_balancer_enabled
must be specifiedSteps to Reproduce
terraform plan
Important Factoids
No response
References
No response