terraform-provider-azurerm icon indicating copy to clipboard operation
terraform-provider-azurerm copied to clipboard

Support for ``infrastructure_resource_group_name`` on ``azurerm_container_app_environment`` without ``workload_profile``

Open mschwrdtnr opened this issue 1 year ago • 5 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Community Note

  • Please vote on this issue by adding a :thumbsup: reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment and review the contribution guide to help.

Description

Hi together! I am happy, that since some weeks it's possible to use infrastructure_resource_group_name on azurerm_container_app_environment. Implemented in https://github.com/hashicorp/terraform-provider-azurerm/pull/24361.

The problem is that it's necessary to set workload_profile {} and workload profiles only allows values of "["D4" "D8" "D16" "D32" "E4" "E8" "E16" "E32"]".

I want to use the consumption workload_profile and also set the change the value for infrastructure_resource_group_name. It should not be necessary to specify workload_profile to set the resource group name of the infrastructure, in my opinion.

If I want to deploy without workload_profiles {} I get the following error: │ "infrastructure_resource_group_name": all of `infrastructure_resource_group_name,workload_profile` must be specified.

New or Affected Resource(s)/Data Source(s)

azurerm_container_app_environment

Potential Terraform Configuration

resource "azurerm_container_app_environment" "cae_test" {
  name                           = "cae-name"
  location                       = var.location
  resource_group_name            = "rg-cae-test"
  log_analytics_workspace_id     = <log_analytics-id>
  infrastructure_subnet_id       = <subnet-id>
  internal_load_balancer_enabled = true
  infrastructure_resource_group_name = "rg-cae-test-aks"
}

References

https://github.com/hashicorp/terraform-provider-azurerm/pull/24361

mschwrdtnr avatar Feb 19 '24 18:02 mschwrdtnr

Hi @mschwrdtnr 👋!

I've implemented it, and during my testing I noticed that it was only picked up in combination with a workload_profile.

If you have an example of it working with a consumption workload profile using az cli or portal, please let me know.

aristosvo avatar Feb 20 '24 15:02 aristosvo

Hi @aristosvo ! Thanks for your reply.

Sorry, I don't understand what example you want me to provide with az. I want to use the following terraform code to rename the infrastructure resource group. It should not be necessary to set workload_profile to use infrastructure_resource_group_name. Like I wrote: I am getting an error if I not specify workload_profile but I dont want to because I use consumption only.

resource "azurerm_container_app_environment" "cae_test" {
  name                           = "cae-name"
  location                       = var.location
  resource_group_name            = "rg-cae-test"
  infrastructure_subnet_id       = <subnet-id>
  internal_load_balancer_enabled = true
  infrastructure_resource_group_name = "rg-cae-test-aks"
}

mschwrdtnr avatar Feb 21 '24 08:02 mschwrdtnr

Hi @mschwrdtnr !

I think this is simply not possible and available as functionality in the Azure REST APIs.

The easiest to invalidate that is that you have proof that it is possible via other (azapi or non-terraform) ways to do the things you want. In that case I'll simply backtrack their interaction with the Azure REST APIs and implement it in azurerm.

aristosvo avatar Feb 21 '24 11:02 aristosvo

@aristosvo Ahh got it! Thanks for the clarification. I'll try to test it.

mschwrdtnr avatar Feb 21 '24 11:02 mschwrdtnr

I was able to provision container apps environment specifying infrastructure resource group name and without workload profile via az cli:

az extension add --name containerapp
az containerapp env create -n web-platform -g web-platform --location northeurope --infrastructure-resource-group managed-container-app --infrastructure-subnet-resource-id "/subscriptions/<edited>/resourceGroups/infrastructure/providers/Microsoft.Network/virtualNetworks/dev/subnets/container_app_env"

terraform code:

resource "azurerm_container_app_environment" "web_platform" {
  name                               = "web-platform"
  location                           = azurerm_resource_group.web_platform.location
  resource_group_name                = azurerm_resource_group.web_platform.name
  infrastructure_subnet_id           = azurerm_subnet.subnets["container_app_env"].id
  infrastructure_resource_group_name = "managed-container-app"
  tags                               = local.tags
}

result:

│ Error: Unsupported argument
│ 
│   on container_app.tf line 46, in resource "azurerm_container_app_environment" "web_platform":
│   46:   infrastructure_resource_group_name = "managed-container-app"
│ 
│ An argument named "infrastructure_resource_group_name" is not expected here.
╵

AurimasNav avatar Feb 28 '24 07:02 AurimasNav

This issue was fixed by https://github.com/hashicorp/terraform-provider-azurerm/pull/25285

mschwrdtnr avatar Apr 09 '24 07:04 mschwrdtnr

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

github-actions[bot] avatar May 10 '24 02:05 github-actions[bot]