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

Error azurerm_monitor_diagnostic_setting produced an unexpected new value: Root resource was present, but now absent for trafficmanager and frontdoor #25676

Closed
1 task done
raghavendra3553 opened this issue Apr 19, 2024 · 4 comments · Fixed by #27088

Comments

@raghavendra3553
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.5.7

AzureRM Provider Version

3.85.0

Affected Resource(s)/Data Source(s)

azurerm_monitor_diagnostic_setting

Terraform Configuration Files

#
terraform {
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "3.85.0"
    }
    azuread = {
      source  = "hashicorp/azuread"
      version = "~> 2.46.0"
    }
  }

  required_version = ">=0.14.9"

  backend "azurerm" {
  }
}

resource "azurerm_monitor_diagnostic_setting" "fdazurediagnostics" {
  count                      = length(var.loganalyticsworkspaceid) > 0 ? 1 : 0

  name                       = format("%s-analytics", var.name)
  target_resource_id         = var.targetresourceid
  log_analytics_workspace_id = var.loganalyticsworkspaceid

  enabled_log {
    category_group = "AllLogs"
    retention_policy {
      enabled = false
    }
  }

  metric {
    category = "AllMetrics"
    enabled  = true
    retention_policy {
      enabled = false
    }
  }
  lifecycle {
    ignore_changes = [log, metric, log_analytics_destination_type]
  }
}

resource "azurerm_monitor_diagnostic_setting" "fdazurediagnosticssecurity" {
  count                          = length(var.securityeventhubauthorizationruleid) > 0 ? 1 : 0

  name                           = format("%s-securitylogs", var.name)
  target_resource_id             = var.targetresourceid
  eventhub_name                  = var.securityeventhubname
  eventhub_authorization_rule_id = var.securityeventhubauthorizationruleid

  enabled_log {
    category = "FrontDoorAccessLog"
    retention_policy {
      enabled = false
    }
  }

  lifecycle {
    ignore_changes = [log, metric, log_analytics_destination_type]
  }
}

variables.tf
============================

variable "loganalyticsworkspaceid" {
  type        = string
  description = "Name of Log Analytics workspace. Pass empty string to omit for development purposes"
}

variable "securityeventhubname" {
  type        = string
  description = "Name of Security Event Hub Name. Pass empty string to omit for development purposes"
}

variable "securityeventhubauthorizationruleid" {
  type        = string
  description = "ID of Security Event Hub Auth Rule.  Pass empty string to omit for development purposes"
}


variable "name" {
  type        = string
  description = "Front Door Name"
}

variable "targetresourceid" {
  type = string
}

Debug Output/Panic Output

Error: Provider produced inconsistent result after apply
2024-04-18T09:16:18.5269378Z     stdout: 
2024-04-18T09:16:18.5269501Z     stdout: When applying changes to
2024-04-18T09:16:18.5269987Z     stdout: module.frontdoor["s00803NFD999991sltfm090728dev"].module.fdazurediagnostics[0].azurerm_monitor_diagnostic_setting.fdazurediagnostics[0],
2024-04-18T09:16:18.5270279Z     stdout: provider "provider[\"registry.terraform.io/hashicorp/azurerm\"]" produced an
2024-04-18T09:16:18.5270491Z     stdout: unexpected new value: Root resource was present, but now absent.
2024-04-18T09:16:18.5270841Z     stdout: 
2024-04-18T09:16:18.5271133Z     stdout: This is a bug in the provider, which should be reported in the provider's own
2024-04-18T09:16:18.5816873Z     stdout: issue tracker.
2024-04-18T09:16:18.5817224Z     exit: 1
2024-04-18T09:16:18.5817296Z

Expected Behaviour

Terraform should exit with code 0, the following resources should be created in Azure and placed inside the terraform state.

Actual Behaviour

Error: Provider produced inconsistent result after apply
2024-04-18T09:16:18.5269378Z stdout:
2024-04-18T09:16:18.5269501Z stdout: When applying changes to
2024-04-18T09:16:18.5269987Z stdout: module.frontdoor["s00803NFD999991sltfm090728dev"].module.fdazurediagnostics[0].azurerm_monitor_diagnostic_setting.fdazurediagnostics[0],
2024-04-18T09:16:18.5270279Z stdout: provider "provider["registry.terraform.io/hashicorp/azurerm"]" produced an
2024-04-18T09:16:18.5270491Z stdout: unexpected new value: Root resource was present, but now absent.
2024-04-18T09:16:18.5270841Z stdout:
2024-04-18T09:16:18.5271133Z stdout: This is a bug in the provider, which should be reported in the provider's own
2024-04-18T09:16:18.5816873Z stdout: issue tracker.
2024-04-18T09:16:18.5817224Z exit: 1
2024-04-18T09:16:18.5817296Z

Steps to Reproduce

terraform plan and apply. We are seeing consistently this issue to trafficmanager and frontdoor, azure side it is created successfully

Important Factoids

No response

References

No response

@rcskosir
Copy link
Contributor

Thank you for taking the time to open this issue. Please subscribe to PR #25697 created by @teowa for this issue.

@raghavendra3553
Copy link
Author

Thanks for quick fix and we need to know when this fix will be available because this fix is really important for our product. Is there any can we prioritize the fix to megre.

@teowa
Copy link
Contributor

teowa commented Jun 4, 2024

Hi @raghavendra3553 , I am not sure if it is unstable API or other factor, I cannot repro the Root resource was present, but now absent. error for diagnostic setting in my local now. Can you or anyone help provide Terraform debug logs with HTTP logs about PUT diagnostic setting and GET diagnostic setting (I guess it should be 404 returned for the GET after PUT), so I can submit the issue to REST API as suggested in #25697 (review) and push this forward.

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 Sep 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.