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_monitor_diagnostic_setting updating metric and logs on each terraform plan / apply #15906

Closed
MageshSrinivasulu opened this issue Mar 21, 2022 · 2 comments

Comments

@MageshSrinivasulu
Copy link

MageshSrinivasulu commented Mar 21, 2022

Running terraform which below configuration

   azurerm = "~>2.95.0"
   required_version = ">= 0.14.11"

Below is the terraform code that's causing the issue. I am running with all the logs and metrics provided from the data block. Still, metrics and logs are getting updated every single time

data "azurerm_monitor_diagnostic_categories" "storage-diagnostic-categories" {
  resource_id = << Pointing to blob service in storage account >>
}

resource "azurerm_monitor_diagnostic_setting" "diagnostic-ehaudit" {
  name                           = << Name of the monitor setting >>
  target_resource_id             = << Pointing to blob service in storage account >>
  eventhub_authorization_rule_id = << Corresponding rule id >>
  eventhub_name                  = << Event hub name>>

  dynamic "log" {
    for_each = data.azurerm_monitor_diagnostic_categories.storage-diagnostic-categories.logs
    content {
      category = log.value
      enabled  = var.logs_enabled
      retention_policy {
        days    = 30
        enabled = var.logs_enabled
      }
    }
  }
  dynamic "metric" {
    for_each = data.azurerm_monitor_diagnostic_categories.storage-diagnostic-categories.metrics
    content {
      category = metric.value
      enabled  = var.metrics_enabled
      retention_policy {
        days    = 30
        enabled = var.metrics_enabled
      }
    }
  }
}

Terraform plan :

       - log {
          - category = "StorageDelete" -> null
          - enabled  = true -> null

          - retention_policy {
              - days    = 30 -> null
              - enabled = true -> null
            }
        }
      - log {
          - category = "StorageRead" -> null
          - enabled  = true -> null

          - retention_policy {
              - days    = 30 -> null
              - enabled = true -> null
            }
        }
      - log {
          - category = "StorageWrite" -> null
          - enabled  = true -> null

          - retention_policy {
              - days    = 30 -> null
              - enabled = true -> null
            }
        }
      + log {
          + category = (known after apply)
          + enabled  = (known after apply)

          + retention_policy {
              + days    = (known after apply)
              + enabled = (known after apply)
            }
        }

      - metric {
          - category = "Capacity" -> null
          - enabled  = false -> null

          - retention_policy {
              - days    = 0 -> null
              - enabled = false -> null
            }
        }
      - metric {
          - category = "Transaction" -> null
          - enabled  = false -> null

          - retention_policy {
              - days    = 0 -> null
              - enabled = false -> null
            }
        }
      + metric {
          + category = (known after apply)
          + enabled  = (known after apply)

          + retention_policy {
              + days    = (known after apply)
              + enabled = (known after apply)
            }
        }

Steps to reproduce :


- terraform apply
- terraform plan
- terraform apply

@tombuildsstuff
Copy link
Contributor

tombuildsstuff commented Mar 21, 2022

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.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants