Skip to content

coralogix_alerts_scheduler fails with 'Invalid uuid' error when resource is manually deleted outside terraform #430

@akugelblitz

Description

@akugelblitz

Affected Resource(s)

  • coralogix_alerts_scheduler

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

provider "coralogix" {
  # api_key = ""
  env = "AP1"
}

terraform {
  required_version = ">= 1.0"
  required_providers {
    coralogix = {
      source  = "coralogix/coralogix"
      version = "2.2.3"
    }
  }
}



locals {
  // Build predicates from map of key -> value
  _predicates = [
    for k, v in var.group_by_keys : format("($d.%s:string =='%s')", trimspace(k), replace(trimspace(v), "'", "\\'") )
  ]

  generated_what_expression = length(local._predicates) > 0 ? format("source logs | filter %s", join("&&", local._predicates)) : null

  final_what_expression = coalesce(var.what_expression, local.generated_what_expression)

  // Convert meta_labels map(string) -> list(object({ key, value })) as expected by provider
  _meta_labels_list = [for k, v in var.meta_labels : { key = k, value = v }]
  meta_labels_final = length(local._meta_labels_list) > 0 ? local._meta_labels_list : null
}

resource "coralogix_alerts_scheduler" "suppression_rule" {
  name        = var.name
  description = var.description
  enabled     = var.enabled
  meta_labels = local.meta_labels_final 

  filter = {
    alerts_unique_ids = var.alerts_list
    what_expression   = local.final_what_expression
  }

  schedule = {
    operation = "mute" 
    one_time = null 
    recurring = {
      dynamic = var.recurring_dynamic
    } 
  }
}

Debug Output

Gist Link

Panic Output

  • None

Expected Behavior

  • After the alert scheduler rule is deleted manually in the Coralogix console, a subsequent terraform apply should detect drift and recreate the coralogix_alerts_scheduler resource (or otherwise reconcile state) without error. If recreation is required, the provider should perform a replace (delete/create) rather than an update call that depends on a now-missing identifier.

Actual Behavior

  • Provider attempts to update the deleted alert scheduler rule and fails with: Invalid uuid for alertSchedulerRule.uniqueIdentifier. Terraform cannot self-heal the drift.

Steps to Reproduce

  1. Create an alerts scheduler via Terraform (coralogix_alerts_scheduler).
  2. Delete the corresponding alert scheduler in the Coralogix console.
  3. Run terraform apply.

Observed: plan shows an in-place update; apply fails with Invalid uuid.

References

  • N/A

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions