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

azurerm_container_app_environment throws error when log analytics workspace located in different subscription #25514

Open
1 task done
Chasermistrz opened this issue Apr 4, 2024 · 6 comments

Comments

@Chasermistrz
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Community Note

  • Please vote on this issue by adding a 👍 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.

Terraform Version

1.7.5

AzureRM Provider Version

3.97.1

Affected Resource(s)/Data Source(s)

azurerm_container_app_environment

Terraform Configuration Files

data "azurerm_container_app_environment" "app_env" {
  name                = "my-aca-env"
  resource_group_name = "aca-rg"
}

Debug Output/Panic Output

│ Error: retrieving Log Analytics Workspace: no matching workspace found
│ 
│   with data.azurerm_container_app_environment.app_env,
│   on data.tf line 44, in data "azurerm_container_app_environment" "app_env":
│   44: data "azurerm_container_app_environment" "app_env" {
│ 
│ retrieving Log Analytics Workspace: no matching workspace found

Expected Behaviour

Data source should be propagated successfully without error.

Actual Behaviour

azurerm_container_app_environment data source throws error when log analytics workspace assigned to Azure Container Apps environment (Monitoring -> Logging options -> Logs Destination -> Azure Log Analytics) is located in different subscription. The last working version of provider is 3.73.0, bug was introduced in #23298, 3.74.0 and newer versions are affected.

Steps to Reproduce

  1. Create Azure Container Apps environment with assigned log analytics workspace from different subscription than environment (same tenant)
  2. Attach its name and resource group name to azurerm_container_app_environment data source
  3. terraform plan

Important Factoids

No response

References

#23298

@MatthewJNixon
Copy link

MatthewJNixon commented Apr 18, 2024

Hi guys,

We've encountered the exact same thing with the following setup with azurerm_container_app and azurerm_container_app_environment:

Terraform Version
1.7.5

AzureRM Provider Version
3.98.0

Dev Subscription:
Container App Environment

  • Container App (or Job)
    Management Subscription:
    Log Analytics Workspace

We can create the Container App Environment under TF using azurerm linking to the Management Subscription log analytics workspace. Once we then began deploying Container Apps we encountered the exactly same Error: retrieving Log Analytics Workspace: no matching workspace found . We circumvented this by linking the child container app/job to the LAW via ID, e.g.

resource "azurerm_container_app" "some_container_app" {
  name = "some-container-app"
  container_app_environment_id = "/subscriptions/*****/resourceGroups/some-resource-group/providers/Microsoft.App/managedEnvironments/some-container-app-environment"
  resource_group_name          = "some-child-resource-group
# The rest of the azurerm_container_app definition

rather than using a data "azurerm_container_app_environment" block

Hope this helps others!

@mapperCoderZ
Copy link

Hello, I have this bug appearing when I try to create a azurerm_container_app_environment_custom_domain to an existing container app environment linked to a LAW in another subscription too. It's anoying because the previous workaround does not seem to work for me.

│ Error: retrieving Log Analytics Workspace: no matching workspace found
│ 
│   with module.container_apps.azurerm_container_app_environment_custom_domain.container_app_environment_domain,
│   on ../../../../**********/modules/azure/containerapps/container_app_environment.tf line 31, in resource "azurerm_container_app_environment_custom_domain" "container_app_environment_domain":
│   31: resource "azurerm_container_app_environment_custom_domain" "container_app_environment_domain" {
│ 
│ retrieving Log Analytics Workspace: no matching workspace found

@sohocine
Copy link

This bug is still occuring as of azurerm 3.115.0
Any planned resolution?

@pmatthews05
Copy link

Any new on this issue? Any idea of a fix?

@sohocine
Copy link

The issue always happens when your Log Analytics is created in another Resource Group than Container Apps Environment's RG

@felixZdi
Copy link

This really blocks us in regards of using centralized log analytic workspaces

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants