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 should not require a log_analytics_workspace_id #20748

Closed
1 task done
zioproto opened this issue Mar 2, 2023 · 7 comments · Fixed by #22733
Closed
1 task done

azurerm_container_app_environment should not require a log_analytics_workspace_id #20748

zioproto opened this issue Mar 2, 2023 · 7 comments · Fixed by #22733

Comments

@zioproto
Copy link
Contributor

zioproto commented Mar 2, 2023

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

Terraform Version

1.3.9

AzureRM Provider Version

v3.45.0

Affected Resource(s)/Data Source(s)

azurerm_container_app_environment

Terraform Configuration Files

resource "azurerm_resource_group" "example" {
  name     = "tf-aca-rg"
  location = "eastus"
}

resource "azurerm_container_app_environment" "example" {
  name                       = "mytfaca"
  location                   = azurerm_resource_group.example.location
  resource_group_name        = azurerm_resource_group.example.name
}

resource "azurerm_container_app" "example" {
  name                         = "example-app"
  container_app_environment_id = azurerm_container_app_environment.example.id
  resource_group_name          = azurerm_resource_group.example.name
  revision_mode                = "Single"

  template {
    container {
      name   = "examplecontainerapp"
      image  = "mcr.microsoft.com/azuredocs/containerapps-helloworld:latest"
      cpu    = 0.25
      memory = "0.5Gi"
    }
  }
}

Debug Output/Panic Output

│ Error: Missing required argument
│
│   on main.tf line 6, in resource "azurerm_container_app_environment" "example":
│    6: resource "azurerm_container_app_environment" "example" {
│
│ The argument "log_analytics_workspace_id" is required, but no definition was found.

Expected Behaviour

The log_analytics_workspace_id should not be required. With the CLI it is possible to create a container app with --logs-destination none in case the logs are handled manually in the application by a third party solution:

Example:

az containerapp env create --name nologsmyaca -g aca --location eastus --logs-destination none

With Terraform is not possible to create a Container App with this equivalent configuration

Actual Behaviour

log_analytics_workspace_id is required forcing the creation of the Log Analytics Workspace.

Steps to Reproduce

terraform plan

Important Factoids

No response

References

No response

@zioproto zioproto added the bug label Mar 2, 2023
@github-actions github-actions bot removed the bug label Mar 2, 2023
@zioproto
Copy link
Contributor Author

zioproto commented Mar 2, 2023

I intercepted the PUT method with mitmproxy when I create the containerapp env using az-cli.

Running this command:

az containerapp env create --name nologsmyaca -g aca --location eastus --logs-destination none

Results in this:

{
    "location": "eastus",
    "properties": {
        "appLogsConfiguration": {
            "destination": null,
            "logAnalyticsConfiguration": null
        },
        "customDomainConfiguration": null,
        "daprAIInstrumentationKey": null,
        "internalLoadBalancerEnabled": null,
        "vnetConfiguration": null,
        "zoneRedundant": false
    },
    "sku": {
        "name": "Consumption"
    },
    "tags": null
}

@zioproto
Copy link
Contributor Author

In addition, we should make sure that changing log_analytics_workspace_id does not trigger the destroy and recreate of the resource. The customer should be able to point to a different log analytics workspace id during operations.

@leandroscardua

This comment was marked as duplicate.

1 similar comment
@leandroscardua

This comment was marked as outdated.

@ctnoz
Copy link

ctnoz commented Jul 13, 2023

Any update on this bug?

When deploying container apps environment in the portal, I can choose one of the following logging options:

  1. log analytics
  2. azure monitor (diagnostic settings)
  3. none

But in terraform, I cannot choose a logging option other than log analytics. This is because log_analytics_workspace_id is a required argument for azurerm_container_app_environment and cannot be set to null. This prevents me from enabling diagnostic settings instead of log analytics.

I can still define diagnostic settings alongside log analytics with no conflicts in terraform, but log analytics takes precedence during deployment. Therefore, after deploying with terraform, I have to manually switch logging options from log analytics to azure monitor (diagnostic settings) in the portal. Only then does it disable log analytics and enable diagnostic settings with the details (metrics, storage account, eventhub, etc.) I defined in the terraform code.

@Sefriol
Copy link

Sefriol commented Jul 17, 2023

Agreed. Terraform config should match possible logging options in Azure Portal.

Copy link

github-actions bot commented May 9, 2024

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 github-actions bot locked as resolved and limited conversation to collaborators May 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
6 participants