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 Version 2.42.0 casing issues with respect to Log Analytics Workspace Id leads to replacement of Azurerm Monitor Diagnostic Setting resource #10165

Closed
gro1m opened this issue Jan 13, 2021 · 3 comments

Comments

@gro1m
Copy link
Contributor

gro1m commented Jan 13, 2021

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

Terraform Version: 0.13.0
AzureRM Provider Version: 2.42.0

Affected Resource(s)

  • azurerm_monitor_diagnostic_setting

Terraform Configuration Files

locals {
  sub_id = var.subscription_id
  rg_name = "monitoring-rg"
  law_type = "Microsoft.operationalinsights"
  law_name = "xxxx-law"
  law_id = join("/", [local.sub_id, "resourcegroups", local.rg_name, "providers", local.law_type, "workspaces", local.law_name])
  diagnostics_name = "SubscriptionActivityLogToAnalyticsWS"
}

resource "azurerm_monitor_diagnostic_setting" "monitoring_subscription_diagnostics" {
  name  = local.diagnostics_name
  target_resource_id = local.sub_id
  log_analytics_workspace_id = local.law_id

  # just Administrative, Security and Alert Events are enabled for the moment
  log {
    category = "Administrative"
    enabled  = true
    retention_policy {
      enabled = false
    }
  }

  log {
    category = "Security"
    enabled  = true
    retention_policy {
      enabled = false
    }
  }

  log {
    category = "Alert"
    enabled  = true
    retention_policy {
      enabled = false
    }
  }

  log {
    category = "ServiceHealth"
    enabled  = false
    retention_policy {
      enabled = false
    }
  }

  log {
    category = "Recommendation"
    enabled  = false
    retention_policy {
      enabled = false
    }
  }

  log {
    category = "Policy"
    enabled  = false
    retention_policy {
      enabled = false
    }
  }

  log {
    category = "Autoscale"
    enabled  = false
    retention_policy {
      enabled = false
    }
  }

  log {
    category = "ResourceHealth"
    enabled  = false
    retention_policy {
      enabled = false
    }
  }
}

Debug Output

Panic Output

Expected Behaviour

The log_analytics_workspace_id casing of Microsoft.OperationalInsights and resourceGroups should not lead to a replacement of the diagnostic setting.

Actual Behaviour

-/+ resource "azurerm_monitor_diagnostic_setting" "monitoring_subscription_diagnostics" {
      ~ id                         = "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx|SubscriptionActivityLogToAnalyticsWS" -> (known after apply)
      ~ log_analytics_workspace_id = "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/monitoring-rg/providers/Microsoft.OperationalInsights/workspaces/xxxx-law" -> "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourcegroups/monitoring-rg/providers/microsoft.operationalinsights/workspaces/xxxx-law" # forces replacement
        name                       = "SubscriptionActivityLogToAnalyticsWS"
        target_resource_id         = "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
      + log {
          + category = "Administrative"
          + enabled  = true
          + retention_policy {
              + enabled = false
            }
        }
      - log {
          - category = "Administrative" -> null
          - enabled  = true -> null
        }
      + log {
          + category = "Alert"
          + enabled  = true
          + retention_policy {
              + enabled = false
            }
        }
      - log {
          - category = "Alert" -> null
          - enabled  = true -> null
        }
      + log {
          + category = "Autoscale"
          + enabled  = false
          + retention_policy {
              + enabled = false
            }
        }
      - log {
          - category = "Autoscale" -> null
          - enabled  = false -> null
        }
      + log {
          + category = "Policy"
          + enabled  = false
          + retention_policy {
              + enabled = false
            }
        }
      - log {
          - category = "Policy" -> null
          - enabled  = false -> null
        }
      + log {
          + category = "Recommendation"
          + enabled  = false
          + retention_policy {
              + enabled = false
            }
        }
      - log {
          - category = "Recommendation" -> null
          - enabled  = false -> null
        }
      + log {
          + category = "ResourceHealth"
          + enabled  = false
          + retention_policy {
              + enabled = false
            }
        }
      - log {
          - category = "ResourceHealth" -> null
          - enabled  = false -> null
        }
      + log {
          + category = "Security"
          + enabled  = true
          + retention_policy {
              + enabled = false
            }
        }
      - log {
          - category = "Security" -> null
          - enabled  = true -> null
        }
      + log {
          + category = "ServiceHealth"
          + enabled  = false
          + retention_policy {
              + enabled = false
            }
        }
      - log {
          - category = "ServiceHealth" -> null
          - enabled  = false -> null
        }
    }

Steps to Reproduce

  1. terraform plan
    (optionally: 2. terraform apply)

Important Factoids

Location is WestEurope, but probably does not matter.

References

None

@tombuildsstuff
Copy link
Member

hi @gro1m

Thanks for opening this issue :)

This has been fixed in #10104 and will become available in version v2.43.0 of the Azure Provider - since support for this has been merged I'm going to close this issue for the moment; however I've assigned this to the v2.43.0 milestone so @hashibot will comment when the release is available.

Thanks!

@ghost
Copy link

ghost commented Jan 14, 2021

This has been released in version 2.43.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 2.43.0"
}
# ... other configuration ...

@ghost
Copy link

ghost commented Feb 12, 2021

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Feb 12, 2021
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