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

Cannot create or modify azurerm_monitor_diagnostic_setting #15046

Closed
hobbesuk opened this issue Jan 20, 2022 · 7 comments
Closed

Cannot create or modify azurerm_monitor_diagnostic_setting #15046

hobbesuk opened this issue Jan 20, 2022 · 7 comments

Comments

@hobbesuk
Copy link

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 (and AzureRM Provider) Version 2.92.0

Affected Resource(s)

  • azurerm_monitor_diagnostic_setting

Terraform Configuration Files

resource "azurerm_monitor_diagnostic_setting" "apim" {
  count                      = length(local.locations)
  name                       = "xxxx"
  target_resource_id         = azurerm_api_management.apim[count.index].id
  log_analytics_workspace_id = var.LogAnalyticsWorkspace
  log_analytics_destination_type = "AzureDiagnostics"

  log {
    category = "GatewayLogs"
    enabled = false
    retention_policy {
      days = 30
      enabled = false
    }
  }

  metric {
    category = "AllMetrics"
    retention_policy {
      days = 30
      enabled = false
    }
  }
}

Expected Behaviour

Resource created

Actual Behaviour

Error: creating Monitor Diagnostics Setting "xxxx" for Resource "/subscriptions/xxxx/resourceGroups/xxxx/providers/Microsoft.ApiManagement/service/xxxx-westeurope": insights.DiagnosticSettingsClient#CreateOrUpdate: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="BadRequest" Message="Invalid API Verion used to modify log category group enabled setting: xxxx, please use version post: 2021-05-01-preview"

Steps to Reproduce

  1. terraform apply
@hobbesuk
Copy link
Author

Maybe related to #14333

@tombuildsstuff
Copy link
Contributor

@hobbesuk just to confirm, is this an existing resource which has been imported into Terraform (which is using Log Category Groups) - or a new resource?

Thanks!

@hobbesuk
Copy link
Author

Both, I've tried updating an existing resource that was already in my state file and also trying to create a new one, both fail. I'm not trying to use log category groups.

@hobbesuk
Copy link
Author

hobbesuk commented Feb 4, 2022

If it helps this is what the plan is trying to do:


# azurerm_monitor_diagnostic_setting.apim[0] will be updated in-place
  ~ resource "azurerm_monitor_diagnostic_setting" "apim" {
        id                             = "/subscriptions/xxxx/resourceGroups/xxxx/providers/Microsoft.ApiManagement/service/canary-westeurope|Monitoring"
        log_analytics_destination_type = "AzureDiagnostics"
      ~ log_analytics_workspace_id     = "/subscriptions/xxxx/resourceGroups/xxxx/providers/Microsoft.OperationalInsights/workspaces/analytics-canary" -> "/subscriptions/xxxxx/resourcegroups/xxxx/providers/Microsoft.OperationalInsights/workspaces/analytics-canary"
        name                           = "Monitoring"
        target_resource_id             = "/subscriptions/xxxx/resourceGroups/xxxx/providers/Microsoft.ApiManagement/service/canary-westeurope"

      - log {
          - category = "GatewayLogs" -> null
          - enabled  = false -> null

          - retention_policy {
              - days    = 0 -> null
              - enabled = false -> null
            }
        }
      + log {
          + category = "GatewayLogs"
          + enabled  = false

          + retention_policy {
              + days    = 30
              + enabled = false
            }
        }
      - log {
          - category = "WebSocketConnectionLogs" -> null
          - enabled  = false -> null

          - retention_policy {
              - days    = 0 -> null
              - enabled = false -> null
            }
        }

@hobbesuk
Copy link
Author

hobbesuk commented Feb 4, 2022

I'm more convinced this is a problem because azure have enabled APIM diagnostic settings to use category groups, so we're a bit stuck with tf atm.
image

@tombuildsstuff
Copy link
Contributor

Duplicate of #10388, please subscribe to that issue for updates.

@github-actions
Copy link

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 Apr 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants